In package.json you can mark each dependency with a number of versions to install, then type npm install to install all of the listed dependencies in the specified versions:
Install only 0.6.0 :
{ "devDependencies": { "grunt-contrib-watch": "0.6.0" } }
Prefix with ~ to install the latest fix 0.6.x :
As release 0.6.1 , 0.6.2 , 0.6.3 , etc. Versions of npm install will install the latest version. If 0.7.0 is a release, it will not install this version (usually a good strategy, as it may contain change changes).
{ "devDependencies": { "grunt-contrib-watch": "~0.6.0" } }
Explicitly set the range:
You can use > , < , <= , >= to explicitly set the version range. Another good option for custom ranges or if you want to be explicit with version ranges. The following will install each version greater than or equal to 0.6.0 , but less than 1.0.0 :
{ "devDependencies": { "grunt-contrib-watch": ">= 0.6.0 < 1.0.0" } }
Always install the latest version with *
Or, if you always want the latest version to use * :
{ "devDependencies": { "grunt-contrib-watch": "*" } }
More about version ranges in npm docs: https://www.npmjs.org/doc/misc/semver.html
npm outdated
If you want to know which of your dependencies is deprecated, use npm outdated : https://www.npmjs.org/doc/cli/npm-outdated.html
npm update
Use npm update to update all your dependencies to the latest versions. Or npm update packagename anotherpackage to update certain packages to the latest version.
Kyle robinson young
source share