when i use npm update
, i can update all package , but package version number in package.json not change , in the package.json , have devDependencies
and dependencies
, like this :
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"jquery": "^1.11.2"
},
"devDependencies": {
"lodash": "^2.4.1"
}
}
how to use one line command update all package and all package numbner in devDependencies
and dependencies
will update too.
Simply change every dependency's version to * , then run npm update --save .
To update packages to the latest version, you need to use the npm install <package>@latest command. Keep in mind as these packages introduce a new major version, most likely there are breaking changes from the previous version.
One easy step:
$ npm i -g npm-check-updates && ncu -a && npm i
That is all. All of the package versions in package.json will be the latest.
From npm documentation:
When you want to update a package and save the new version as the minimum required dependency in package.json, you can use:
npm update -S
or
npm update --save
Also As with all commands that install packages, the --dev flag will cause devDependencies to be processed as well. so your desired command is:
npm update --dev --save
Note that npm will only write an updated version to package.json if it installs a new package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With