Update grunt dev Dependencies

I'm relatively new, and not familiar with node yet. I have a Gruntfile template file and a package.json file, which I use in all my projects and modify it as needed. When I start each project, I want to update all the Grunt plugins in Dev Dependencies and package.json, but I don’t know how to quickly and easily do this. Is it possible to update all modules with a single command or do I need to do them individually?

+7
npm gruntjs
source share
2 answers

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.

+17
source share

1. hoice

The grunt-dev-update plugin is my choice.


2. Relevance

This answer applies to February 2018. In the future, the data from this answer may be outdated.

The author of this answer personally used this plugin in February 2018.


3. Argumentation

See plugin description :

Why not use npm update or npm install ?

first - npm update does not work on dev dependencies,
second - npm update remains inside your matching match in your package.json ,
thirdly - npm is not automated as your tasks.


4. Use

Instructions for installation, use and parameters are described in the official description of the plugin .


5. option.semver

strange option name; At first I did not understand what options.semver .

Configuration Example:

 Package name : autoprefixer Package type : devDependencies Current version : 6.7.7 Wanted version : 6.7.7 Latest version : 8.0.0 Package name : browser-sync Package type : devDependencies Current version : 2.23.5 Wanted version : 2.23.6 Latest version : 2.23.6 

You run grunt devUpdate in the console:

If semver: true :

autoprefixer does not update, updating browser synchronization.

elif semver: false :

autoprefixer and update browser synchronization.

0
source share

All Articles