0

I have a Node JS lib with git submodule. When I clone the git repository of my lib, I had to do submodule update --init --recursive something like this to pull the actual stuff from the submodule. After I released the lib and I did npm install my-lib and noticed it's not pulling the git submodule. How do I configure it so it pulls the git submodule? is that even possible?

2 Answers 2

1

I don't think that is possible, as the submodule is, outside of git, just a simple file.

What you can do, however, is using the submodule only in development, compile your library and publish the compiled version in a dist/ folder inside the package.

Then just point main in the package.json to the compiled library script and you can include it in your other projects.

Sign up to request clarification or add additional context in comments.

Comments

0

Indeed, there's not git environment that's installed with npm i, but you could be explicit and in the scripts entry of package.json, add:

 "scripts": {
    "preinstall": "git init && git submodule add -f YOUR_REPO_URL LOCAL_PATH"
  }

Edit: That's however not the best option, because you won't be install to re-install your package. Prefer a simple git clone.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.