Reputation: 2438
I cannot figure out how to update a package installed from a git repository.
Say I have a package at git+ssh://[email protected]:project/my-package.git
and it's already installed.
Now, if I:
then nothing gets updated.
I thought the version
field (from the dependent package.json
of my-package) might raise the problem so I removed it and re-installed the package from scratch. Unfortunately it didn't help, the package is still not being updated.
Any ideas?
Upvotes: 5
Views: 3766
Reputation: 2438
Ok, folks. Suprisingly, it doesn't seem possible to get it working out-of-the-box.
But there is a workaround. Thanks to @RobC for pointing me out to some old (yet never resolved) issue: https://github.com/npm/npm/issues/1727
The answer is in the last comment:
https://github.com/npm/npm/issues/1727#issuecomment-354124625
Basically, to update a git package you have to re-install it directly using: npm install package-name
.
Example. Say you already have your package installed and added to the dependencies like this:
{
"dependencies": {
"my-package": "git+ssh://[email protected]:prj/my-package.git"
}
}
Now, to get it updated whenever you issue npm i
all you have to do is to create a postinstall
script which would trigger npm i my-package
:
{
"dependencies": {
"my-package": "git+ssh://[email protected]:prj/my-package.git"
},
"scripts": {
"postinstall": "npm update && npm i my-package"
}
}
Now npm i
will be taking more time since it's gonna run install twice. But this is what we have now.
Upvotes: 10