-
Notifications
You must be signed in to change notification settings - Fork 3k
package-lock.json file not updated after package.json file is changed #16866
Comments
I also find this behavior problematic. For now I'm working around it by changing my |
Same problem here with npm 5.0.0 and node 7.3.0 on macOS. $ 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 |
If you run |
I think adding |
|
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. |
@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?? |
Put If we wanted Edit: I merely wanted to highlight that |
@jakeNiemiec It helps the people who had their builds sped up by whole minutes due to |
I don't get it. So what are you supposed to do after you update your package.json? Run |
Do we just need a This just generates the shrinkwrap with current dependencies (so has the effect of updating the lock if you've added a new dependency to |
@fxck after reading @BigstickCarpet 's comment, I added this to my package.json in the scripts section: |
@Maziar-Fotouhi don't forget a
I only do this because updating 'individual packages' was removed. I can't: |
@jakeNiemiec That makes sense. I change the version numbers directly in package.json. Maybe that can help.
|
This nasty error that intertwines with this issue, at least for me. I have found that removing |
@jakeNiemiec Thank you for sharing that! Sounds like you had a lot of fun with this issue! |
@jakeNiemiec Thanks, following your advice, i simply added this line to my .npmrc file. |
Removing node_modules is good as a workaround but it is overkill in my opinion. It would also not be viable for large projects that have 5+ min install times due to native build steps. Deleting package-lock.json each time seems kludgy and creates problems for automated tools like npm-check-updates, which I maintain. Users of npm-check-updates as well as users who hand edit their package.json need a way to regenerate the package-lock.json file without having to reinstall all modules. |
Isn't the purpose of I do agree that this can be bothersome if you're not expecting this behavior by default. I wouldn't, however, say that this is a bug or anything. |
@Ketamin I initially did this, but this won't work for anyone else using your package (in my case: co-workers). I was hoping it was temporary, but after seeing #16991 it's probably better to downgrade to @kapadiamush I would expect that Use case:
I want to update
At least, thats how I imagined everything should work from personally working with other package locking systems. |
@jakeNiemiec Yeah, it's the other way around.. sorta. It's my understanding that the You don't need to remove |
@kapadiamush I disagree with your interpretation... there are multiple installs possible for a given package.json. The problem arises from the fact that the package.json can be changed before |
@raineorshine That actually makes a lot more sense regarding the You should still be able to update the |
I have over 750MB of dependencies, so removing For the time being, I'm going back to npm@4 at least until version 5 becomes the de-facto standard in the industry. |
I am absolutely on board with @jakeNiemiec 's interpretation. |
@albertosantini That is not what I am seeing.
package.json:
If I If I |
@wulfsberg I am glad someone else is understanding the problem now, npm install is causing the newest version of a package to be installed, ignoring the lock file. In my eyes this completely defeats the point of having a lock file, and I might as well not include it as it's not locking anything. |
@wulfsberg is the All in all, I think you have a valid point as right now there is no way (at least that I know of!) to just read from the lock files and not the package.json. Maybe a new option can be added to the npm install command in future (E.g. But this is not the right thread for that. I believe a new feature request must be created for that. For now, you can do what I am doing. Only use exact version numbers. This means another thing to do for you as you will have to update your packages manually, but it also gives you much more control over the details which is always good. Another command that can be useful if you decide to do this, is |
@Maziar-Fotouhi No, it is not. I was referring to (and disagreeing with) @albertosantini's #16866 (comment) case 1 and #16866 (comment) which state it should. |
@Maziar-Fotouhi thank you for your suggestion. Having a way to create a static and repeatable installation is essential for testing as currently with version 5.3.0 I can not do this. A new flag such as --lock or --read-only would allow npm install to ONLY install from the lock file, and would then give a repeatable installation every time. How can I request this? It is something I feel is incredibly important as currently version 5.3.0 is completely unusable in this situation. |
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. |
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 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?
|
It already works that way. Scroll up to my first comments to see an example
of this.
|
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. |
@scottmas please see this comment #17979 (comment) by @iarna. |
should we turn off the package-lock in .npmrc or not to avoid install errors? |
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? |
@NathanCH It looked like things were fixed in 5.4.x What happened? |
See #18286 for the addition of a |
I can confirm that clearing the package lock file, the issue is solved |
If anyone needs to support Windows, this appears to work for our team: {
"scripts": {
"clean": "rm -Rf node_modules/ && rm -f ./package-lock.json && npm cache clean -f",
"clean_windows": "IF EXIST node_modules rd /s /q node_modules && IF EXIST package-lock.json DEL package-lock.json && npm cache clean -f",
"rebuild": "npm run clean && npm i",
"rebuild_windows": "npm run clean_windows && npm i"
}
} After running |
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 |
Manually updating a |
I'm opening this issue because:
What's going wrong?
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 thepackage-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.xnode -v
prints: 7.x.xnpm config get registry
prints: private oneThe text was updated successfully, but these errors were encountered: