-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npm update does not save new versions in package.json #2704
Comments
I experienced this bug on Windows, NPM version 6.14.11. Interestingly, it seemed my global packages were also messed up around the same time this started. For instance, I was able to fix this by completely uninstalling node, npm, Windows build tools, and chocolatey. I deleted all the related folders in my user folder, programs folder, %appdata%, %localappdata%, and %programdata%. A simple node/npm update wouldn't fix it, so something was messed up in one of those folders. After re-install of node/npm, package.json was updating as expected and the global packages issue was resolved. |
Same bug on windows 10 node v12.16.0 |
@saltire sorry for the confusion, we need to update the docs to clarify that |
And what command can I use to update all packages, modifying specs in package.json? |
There should be a better way than running |
Since what I want to do is update the versions listed in package.json to the latest "Wanted" version and not the "Latest" version (as shown by I have my package versions set to "want" the latest non-breaking changes if semver is respected. I use the version in the package.json to help me know the version I actually last got and tested locally. When a non-breaking change actually breaks something, I update package.json to lock the previous version, report the issue and track the package for a fix. I'm also wondering what the rationale for the breaking change was. There was already an option |
I was extremely surprised when |
Still not sure how to update all packages and change package.json |
Several people recommended me npm package for dependencies updates. Maybe it will be useful for somebody. |
Using a package to update packages is so weird. This is not the way it should be. By the way is there a way for the package to do "exactly" what npm update was doing before? |
You can write your own script something like this const {execSync} = require('child_process')
const packageName = process.argv[2]
const outdatedInfo = JSON.parse(execSync(`npm outdated -l --json ${packageName}`))
const packageCurrentVersion = outdatedInfo[packageName].current
const packageWantedVersion = outdatedInfo[packageName].wanted
const packageType = outdatedInfo[packageName].type
const isDev = packageType === 'devDependencies'
const updateInfo = execSync(`npm i ${isDev ? '-D' : ''} ${packageName}@${packageWantedVersion}`)
console.log(updateInfo.toString()) And then use I know it's not a good solution but why not? |
@srknzl |
I mean why other 3rd party package if DeFacto standard is npm package |
This, is a serious breaking change / issue when migrating to v7, and this is not documented anywhere at this time: I just noticed that during migration. The important questions now are:
Thanks for taking the time to give a clear answer to the community 😉 |
For now, I decided not to upgrade to npm >= 7. With this behavior, I lose track of what is happening with my project, which dependencies I am upgrading, and which still need to be upgraded (via the Regards. |
Stumbled upon this issue after upgrading npm, skimmed another issue thread and this one; at least two maintainers claim that this was an intentional breaking change, yet I can't find the rationale behind it (in fact, I wasn't even able to find any mention of it in the npm v7 changelogs at first glance). I'm fine with adjusting my workflow, but at the moment I can't quite figure out how this new behavior of |
@npm/cli-team please let us know, How the hell can we update all modules in package.json dependencies to their latest, from now on??? |
For now I have not found any alternative to |
There’s also, |
NPM Version 7 feels like if some .NET lovers have sneaked into the npm development team and trying to ruin the JS development experience. |
@CageFox @arash-bizcover the fact is npm@6 never udpated package.json beyond the specs defined within itself. It might be controversial because it is a breaking change with npm@6, but there is little point in automatically evolving this file. If you distributed an app, you should be distributing a shrinkwarp file. If you distributed a library, you'd only bump the specs in package.json when manually conducting a major upgrade. See also #708 (comment) and npm/feedback#270 |
and yet, it’s a range. |
Sorry I don't understand. How is "millify": "3.5.2" a range? Doesn't that mean 3.5.2 exactly? |
No, i mean “=3.5.2” is a range - one that contains exactly one version. |
Will this get addressed? |
I recently updated to npm 8.3.0 and I received the "pleasant" surprise just like all of you. Since it seems that nothing has changed for more than an year, I'm really worried and I wonder if I should revert back to npm v6 or keep up with v8. If there was any hint that this behavior will be restored or at least introduced as an optional argument, I would stick to v8. |
Previously `npm update` was not respecting the `save` option, it would be impossible for users to use `npm update` and automatically update their `package.json` files. This fixes it by adding extra steps on `Arborist.reify._saveIdealTree` to read direct dependencies of any `package.json` and update them as needed when reifying using the `update` and `save` options. Fixes: npm#708 Fixes: npm#2704 Relates to: npm/feedback#270
@jginsburgn @hardmaster92 Sorry but, as critical as this looks for you, could you please read the whole thread and the linked discussions before commenting that? |
Previously `npm update` was not respecting the `save` option, it would be impossible for users to use `npm update` and automatically update their `package.json` files. This fixes it by adding extra steps on `Arborist.reify._saveIdealTree` to read direct dependencies of any `package.json` and update them as needed when reifying using the `update` and `save` options. Fixes: npm#708 Fixes: npm#2704 Relates to: npm/feedback#270
The team has decided that fixing usage of
|
It seems the issue resolved and now we can move to actual npm too |
@ruyadorno Great news! Big thanks for that 🎉 |
|
@sla100 legacy-peer-deps should be avoided; that's just papering over your invalid dependency graph, and since engines is purely advisory, |
Is it? The comments above suggest save=false is the default in 8.3.2? |
@matthewmayer it's the default for update, but i believe |
This is a best mode for the project. The first level of |
That will break a lot of setups (the same ones yarn pnp and pnpm break). Packages expect the hoisting npm does. |
For example if you run Then your package.json will look like this:
if you then run on npm@6 nothing is changed but if you then run on npm@8.3.2
package.json is updated to
and then if you run
|
I ran into the same issue as well. This could potentially break some production apps, since pinning a dependency to a specific version is rather common and can slip through code reviews quite easily. |
Agree for the code reviews. Much easier to review |
This was fixed in npm@8.4.0, thanks @ruyadorno ! |
v=8.11.0 |
Same for version |
There’s no point in trying a non-latest version of npm - if you’re still having problems with the latest version, please file a new issue. |
Same for version |
Please open a new issue for any bugs or regressions with |
Current Behavior:
When running
npm update
, packages are updated normally, package-lock.json is updated, but package.json is not. (npm install [package]@[version]
does update package.json as expected.)Expected Behavior:
The package.json file should be updated with the newly installed versions, as specified in the npm-update docs.
Steps To Reproduce:
npm update
Environment:
OS: Mac OS Big Sur
Node: 14.15.5
NPM: 7.5.4
The text was updated successfully, but these errors were encountered: