I am relatively new to grunt and am not really familiar with node yet.
I have a boilerplate Gruntfile and package.json file that 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 devDependencies and the package.json, but I don't know of a quick and easy way to do this.
Is it possible to update all modules with one command or do I have to do them individually?
Thanks.
Installing a specific version If you need a specific version of Grunt or a Grunt plugin, run npm install grunt@VERSION --save-dev where VERSION is the version you need. This will install the specified version, adding it to your package. json devDependencies. Note that a tilde version range will be used in your package.
In your package.json
you can tag each dependency with a range of versions to install then type npm install
to install all the listed dependencies at the given versions:
Only install 0.6.0
:
{
"devDependencies": {
"grunt-contrib-watch": "0.6.0"
}
}
Prefix with ~
to install the latest patch version 0.6.x
:
As 0.6.1
, 0.6.2
, 0.6.3
, etc versions are released, npm install
will install the latest version of those. If 0.7.0
is release, it will not install that version (generally a good strategy as it may contain breaking 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 would like to be explicit with your version ranges. The follow will install every version greater or equal than 0.6.0
but less than 1.0.0
:
{
"devDependencies": {
"grunt-contrib-watch": ">= 0.6.0 < 1.0.0"
}
}
Always install the latest with *
Or if you just always want the latest version use *
:
{
"devDependencies": {
"grunt-contrib-watch": "*"
}
}
See more about version ranges in the npm docs: https://www.npmjs.org/doc/misc/semver.html
npm outdated
If you would like to see which of your dependencies are out of date, 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 specific packages to the latest version.
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