I copied package.json from another project and now want to bump all of the dependencies to their latest versions since this is a fresh project and I don't mind fixing something if it breaks.
What's the easiest way to do this?
The best way I know of now is to run npm info express version
then update package.json manually for each one. There must be a better way.
{
"name": "myproject",
"description": "my node project",
"version": "1.0.0",
"engines": {
"node": "0.8.4",
"npm": "1.1.65"
},
"private": true,
"dependencies": {
"express": "~3.0.3", // how do I get these bumped to latest?
"mongodb": "~1.2.5",
"underscore": "~1.4.2",
"rjs": "~2.9.0",
"jade": "~0.27.2",
"async": "~0.1.22"
}
}
I am now a collaborator on npm-check-updates, which is a great solution to this problem.
Alternative is
everytime you use npm update , it automatically update to the latest version. For more version syntax, you may check here: https://www.npmjs.org/doc/misc/semver.html
Solution without additional packages
Change every dependency's version to
*
:Then run
npm update --save
.Some of your packages were updated, but some not?
This is the tricky part, it means your local version of "react" was lower than the newest one. In this case npm downloaded and updated "react" package. However your local version of "react-google-maps" is the same as the newest one.
If you still want to "update" unchanged
*
, you have to delete these modules fromnode_modules
folder.e.g. delete
node_modules/react-google-maps
.Finally run again
npm update --save
.Do not forget to run
npm update --save-dev
if you want to update development dependencies.npm-check-updates
is a utility that automatically adjusts a package.json with the latest version of all dependenciessee https://www.npmjs.org/package/npm-check-updates
To see which packages have newer versions available, then use the following command:
to update just one dependency just use the following command:
For example:
My
package.json
file has dependency:then I should write:
Ncu is a new alias to check for updates. By doing so you do not have to manually update ur version numbers in package.json ncu does it for you . Follow the method below if you are on a Linux machine
If you want to use a gentle approach via a beautiful (for terminal) interactive reporting interface I would suggest using npm-check.
It's less of a hammer and gives you more consequential knowledge of, and control over, your dependency updates.
To give you a taste of what awaits here's a screenshot (scraped from the git page for npm-check):