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.
To update one dependency to its lastest version without having to manually open the
package.json
and change it, you can runi.e.
For reference, npm-install
As noted by user Vespakoen on a rejected edit, it's also possible to update multiple packages at once this way:
He also apports a one-liner for the shell based on
npm outdated
. See the edit for code and explanation.PS: I also hate having to manually edit
package.json
for things like that ;)https://www.npmjs.com/package/npm-check-updates
npm-check-updates allows you to upgrade your package.json dependencies to the latest versions, regardless of existing version constraints.
dependencies updated! thats all!
One easy step:
*
as the version for the latest releases, including unstablelatest
as version definition for the latest stable versionLatestStablePackages
Here is an example:
I really like how npm-upgrade works. It is a simple command line utility that goes through all of your dependencies and lets you see the current version compared to the latest version and update if you want.
Here is a screenshot of what happens after running
npm-upgrade
in the root of your project (next to thepackage.json
file):For each dependency you can choose to upgrade, ignore, view the changelog, or finish the process. It has worked great for me so far.
Updtr!
https://github.com/peerigon/updtr