Search code examples
node.jsnpmpackagenpm-private-modules

Installing private NPM module over GIT, and having it update?


I looked at this answer, which shows you how to install npm modules from private git (sub)folders. This works correctly for me when I do: npm install git+ssh://[email protected]:myaccount/myprivate.git, my main application can then call the code in the private module.

But when someone updates the module in the github.com:myaccount/myprivate.git location, I want my main application to receive these updated changes.

What I want to do is:

  • run npm install on the main application
  • have it update with the new code in the private module
  • ... however the above does NOT update with the new code in the private module

As a work-around I have to:

  • run npm install git+ssh://[email protected]:myaccount/myprivate.git in the main application
  • the new code in the private module is now in the main application
  • ... however I don't want to do this for every single application that is calling the private module. If for example 10 applications are calling my one module, that is many places I need to update manually

Solution

  • You could use git commit hashes to keep track of your changes:

    npm i --save git+ssh://[email protected]:myaccount/myprivate.git#b0f2009
    

    or tags

    npm i --save git+ssh://[email protected]:myaccount/myprivate.git#v0.0.2