You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
package-lock.json file not updated after package.json file is changed #16866
clean project with some deps in package.json.
you run npm i
modules are installed and package-lock.json file is created.
say you update module A in package.json file.
you run npm i. I would expect this updates the package-lock.json file but it doesn't. which results in module A not being updated.
How can the CLI team reproduce the problem?
any project. see description above.
supporting information:
npm -v prints: 5.x.x
node -v prints: 7.x.x
npm config get registry prints: private one
Windows, OS X/macOS, or Linux?: macOS
Network issues:
Geographic location where npm was run:
I use a proxy to connect to the npm registry.
I use a proxy to connect to the web.
I use a proxy when downloading Git repos.
I access the npm registry via a VPN
I don't use a proxy, but have limited or unreliable internet access.
changed the title [-]package-lock.json file not updated after package.json file is updated[/-][+]package-lock.json file not updated after package.json file is changed[/+]on Jun 1, 2017
I also find this behavior problematic. For now I'm working around it by changing my npm install command to rm -f package-lock.json && npm install. Obviously, that's not an elegant solution, and somewhat defeats the purpose of having a lockfile in the first place.
Reacted by cedvdb, Danny Chen, Cameron Loken, Meng Jia, Artem Sapegin, Jason Allen, Yoga Hanggara, Hugo Josefson, Vaidas Keblys, trizzo-lead-virtue and 51 more
Reacted by Søren Nguyen Boisen
Reacted by cedvdb, Samuel Marks, Dexter Miguel, Dhrumil Bhankhar, Carlos Roso, Stanisz Szymon, Atomic Yurec and Gabriele Tomberli
Reacted by cedvdb, Samuel Marks, Mathias Bynens, Dexter Miguel, Daniel Tschinder, Carlos Serrano, Karthik Sagar M V, chasel, Gabriele Tomberli, Jesús Ruiz and 1 more
Same problem here with npm 5.0.0 and node 7.3.0 on macOS.
Each time I add a dependency in my package.json file, I run npm i and I've got this :
$ npm i
removed 3 packages in 5.953s
My new dependencies are not installed after this. I had to delete the package-lock.json and re-run npm i and this time my new dependencies are correctly installed.
If you run npm update package-lock.json gets updated and the new dependency is installed.
Reacted by Kristijan Sedlak, Olaf Kasper, Antonio Essex-Lettieri, gaminoff, karidesousa, gritchie-speedline, Cameron Taggart, 尚新波, Julian Kühnel, Klaas van der Weij and 1 more
Reacted by Artem Sapegin, Jason Allen, Aleš, Dimitry, Karasu, Bastien LE REST, Mantas Marcinkus, Ralf Saenen, John Wright, Achilleas Tsoumitas and 35 more
I think adding npm update command's new option to update only package-lock.json will be a better solution. And then npm install would be better to throw an error or show alerts of the conflicts of the two files.
Reacted by Kesha, Jose Blanco, Jake Niemiec, Artem Sapegin, Raine Revere, Keepcase, Timmy Chang, Kyle Bastien, pito-svk, gritchie-speedline and 3 more
Yea, this has been causing me serious grief the last couple of days. The "speed up" isn't worth the constant requirement to delete my package-lock file every time I need to update a dependency... Changing my package.json never updates my package-lock, and npm update after changing the version doesn't update it either.
Reacted by Andrew Shustariov, Michael Simon, Anri Asaturov, Jake Niemiec, Mark Herhold, Mikael Tilly, Weston Boone, Joseph Rawson, Emilio Martinez, Nikola Ristić and 14 more
we are updating our dependencies automated every moring ... since two days we have a up-to-date package.json file ... but we dont get the new npm cuz the package-lock.json points to the wront version.
to delete the package-lock.json is an absolute useless step ... but fix it.
Put "preinstall": "npm config set package-lock false" in your scripts to disable package-lock.json.
If we wanted yarn, we would have used that. This half-hearted attempt helps no one.
Edit: I merely wanted to highlight that npm should not try and be yarn at the expense of npm. They are both solid package managers built to solve different problems.
Reacted by Mark Herhold, Jake Niemiec, ldrick, Landon Abney, Damien Rajon, William Weckl, Shishir Anshuman, Alex, gritchie-speedline, Tony Kung and 4 more
Reacted by Artem Sapegin, Hugo Josefson, Aleš, Ivar Nilsen, Jan Nowotny, Jon Johnson, Thomas, Christian Bundy, Moritz Gunz, Luis Naia and 13 more
I don't get it. So what are you supposed to do after you update your package.json? Run npm update? I'm getting the same "invalid" messages as @Maziar-Fotouhi does when I try that.
Do we just need a npm lock command like we had npm shrinkwrap?
This just generates the shrinkwrap with current dependencies (so has the effect of updating the lock if you've added a new dependency to package.json).
Reacted by Raine Revere, Nathan, Russell Dempsey, Mark Keith and Jeffrey Meyer
Glad we were able to sort that out, but I feel really bad for those coming from Google and seeing this mess of (mostly true) information on package locks. @zkat or another maintainer might consider locking this issue.
Reacted by Jan Heuermann, Thibaud Colas and mgcnrx11
It seems to me that there's a lot of differing use cases and personal preferences for the package lock file. Generally people like it, but the default behavior doesn't work for everyone. I'm highly doubtful we'll ever be able to find a default behavior that works for everyone.
So why not make the package lock configurable and manually controllable?
For example, why not have a configurable field in .npmrc that lets users disable package-lock? Or another option that you require explicit updates to package-lock.json? (this latter approach is my personal preference)
And then provide devs tools to manually run the package-lock algorithm. Like
npm update-lock mycoolmodule
Those of us who opt non-default behavior will still need a way to configure our package-lock to our liking.
What do you think of this two pronged proposal?
Make package-lock configurable via .npmrc or some other way
Provide low level commands to update and set package-lock
Oh, good point that package-lock.json can already be turned off in .npmrc. But that is the only configuration possible. On or off. It needs to be more tunable. For instance, a setting to make package-lock only update when explicitly updated:
package-lock=explicit-only
And then commands to tune the package lock, such as:
npm update-lock mycoolmodule
Tldr, the fact that .npmrc lets us turn package-lock on or off doesn't get us nearly close enough to making the package-lock workflow customizable.
Has there been any consensus here? I participated in this thread months ago but today got completely ass-bitten by package-lock. Are there any behaviour changes between npm 5.0.x and 5.5.x?
After running npm i <some-package>, those on Windows machines use npm run rebuild_windows to ensure the application's dependencies are actually updated.
Manually updating a package.json should be updating package-lock.json as of several versions ago. If you're not seeing these updates, please first update to the latest npm version before submitting a new issue with specifics. In the meantime, I'm going to lock this thread because I think it'll only be confusing to others if there's folks saying otherwise due to misunderstanding or older versions.
Activity
[-]package-lock.json file not updated after package.json file is updated[/-][+]package-lock.json file not updated after package.json file is changed[/+]JamesMessinger commentedon Jun 1, 2017
I also find this behavior problematic. For now I'm working around it by changing my
npm installcommand torm -f package-lock.json && npm install. Obviously, that's not an elegant solution, and somewhat defeats the purpose of having a lockfile in the first place.yomansk8 commentedon Jun 1, 2017
Same problem here with npm 5.0.0 and node 7.3.0 on macOS.
Each time I add a dependency in my package.json file, I run
npm iand I've got this :$ npm i removed 3 packages in 5.953sMy new dependencies are not installed after this. I had to delete the package-lock.json and re-run
npm iand this time my new dependencies are correctly installed.gyszalai commentedon Jun 2, 2017
If you run
npm updatepackage-lock.json gets updated and the new dependency is installed.falsandtru commentedon Jun 3, 2017
I think adding
npm updatecommand's new option to update only package-lock.json will be a better solution. And thennpm installwould be better to throw an error or show alerts of the conflicts of the two files.treadingwell commentedon Jun 9, 2017
Yea, this has been causing me serious grief the last couple of days. The "speed up" isn't worth the constant requirement to delete my package-lock file every time I need to update a dependency... Changing my package.json never updates my package-lock, and npm update after changing the version doesn't update it either.
hyposimon commentedon Jun 9, 2017
@zone-ghost thats exactly my point
we are updating our dependencies automated every moring ... since two days we have a up-to-date package.json file ... but we dont get the new npm cuz the package-lock.json points to the wront version.
to delete the package-lock.json is an absolute useless step ... but fix it.
is there a way to update the package-lock.json??
jakeNiemiec commentedon Jun 9, 2017
Put
"preinstall": "npm config set package-lock false"in your scripts to disable package-lock.json.If we wanted
yarn, we would have used that. This half-hearted attempt helps no one.Edit: I merely wanted to highlight that
npmshould not try and beyarnat the expense ofnpm. They are both solid package managers built to solve different problems.legodude17 commentedon Jun 9, 2017
@jakeNiemiec It helps the people who had their builds sped up by whole minutes due to
package-lock.jsonfxck commentedon Jun 12, 2017
I don't get it. So what are you supposed to do after you update your package.json? Run
npm update? I'm getting the same "invalid" messages as @Maziar-Fotouhi does when I try that.chrisui commentedon Jun 12, 2017
Do we just need a
npm lockcommand like we hadnpm shrinkwrap?This just generates the shrinkwrap with current dependencies (so has the effect of updating the lock if you've added a new dependency to
package.json).jakeNiemiec commentedon Jun 12, 2017
@Maziar-Fotouhi don't forget a
npm cache clean --forcein there too.I only do this because updating 'individual packages' was removed. I can't:
npm update @me/myCustomDepanymore.99 remaining items
jakeNiemiec commentedon Aug 8, 2017
Glad we were able to sort that out, but I feel really bad for those coming from Google and seeing this mess of (mostly true) information on package locks. @zkat or another maintainer might consider locking this issue.
Removed `package-lock.json`
scottmas commentedon Sep 27, 2017
It seems to me that there's a lot of differing use cases and personal preferences for the package lock file. Generally people like it, but the default behavior doesn't work for everyone. I'm highly doubtful we'll ever be able to find a default behavior that works for everyone.
So why not make the package lock configurable and manually controllable?
For example, why not have a configurable field in
.npmrcthat lets users disable package-lock? Or another option that you require explicit updates to package-lock.json? (this latter approach is my personal preference)And then provide devs tools to manually run the package-lock algorithm. Like
Those of us who opt non-default behavior will still need a way to configure our package-lock to our liking.
What do you think of this two pronged proposal?
jakeNiemiec commentedon Sep 27, 2017
scottmas commentedon Sep 28, 2017
Oh, good point that package-lock.json can already be turned off in .npmrc. But that is the only configuration possible. On or off. It needs to be more tunable. For instance, a setting to make package-lock only update when explicitly updated:
And then commands to tune the package lock, such as:
Tldr, the fact that .npmrc lets us turn package-lock on or off doesn't get us nearly close enough to making the package-lock workflow customizable.
jakeNiemiec commentedon Sep 28, 2017
@scottmas please see this comment #17979 (comment) by @iarna.
vikrantsingh47 commentedon Oct 2, 2017
should we turn off the package-lock in .npmrc or not to avoid install errors?
nathan-charrois commentedon Oct 5, 2017
Has there been any consensus here? I participated in this thread months ago but today got completely ass-bitten by package-lock. Are there any behaviour changes between npm 5.0.x and 5.5.x?
jakeNiemiec commentedon Oct 6, 2017
@NathanCH It looked like things were fixed in 5.4.x
What happened?
alexkreidler commentedon Oct 6, 2017
See #18286 for the addition of a
--from-lock-file(or similar) flag that would install only from thepackage-lock.jsonwithout modifying it.FrancescoBorzi commentedon Oct 26, 2017
I can confirm that clearing the package lock file, the issue is solved
aervin commentedon Nov 24, 2017
If anyone needs to support Windows, this appears to work for our team:
After running
npm i <some-package>, those on Windows machines usenpm run rebuild_windowsto ensure the application's dependencies are actually updated.smithaitufe commentedon Dec 15, 2017
I understand that manually updating package.json won't update package-lock.json.
It is for issues like this that we need package-lock.json removed. Yarn uses yarn.lock and won't stand in our way if we modified package.json
zkat commentedon Dec 16, 2017
Manually updating a
package.jsonshould be updatingpackage-lock.jsonas of several versions ago. If you're not seeing these updates, please first update to the latest npm version before submitting a new issue with specifics. In the meantime, I'm going to lock this thread because I think it'll only be confusing to others if there's folks saying otherwise due to misunderstanding or older versions.