May 25, 2021 Grunt
This document explains in detail how to install the specified version of the Grunt and Grunt plug-ins. If you haven't read the Quick Start Guide, check it out first.
Grunt and Grunt plug-ins should be defined in the
devDependencies section of the project's
package.json
file. T
his allows you to install the module on which the current project depends with one command:
npm install
The current stable and development version of Grunt is
listed on the wiki page
of the project.
If you need a specific version of grunt or Grunt plug-ins,
npm install grunt@VERSION --save-dev
where
VERSION
the version you want.
This completes the installation and adds it to the devDependencies section of the package.json file.
Note that when you add the
--save-dev
tag after the
npm install
command, the
package.json
will appear in the version range of the
wavy line tag.
This is generally good, and when a specified version releases a patch update, the new version is automatically
upgraded and in the semantic
version format defined by semver.
As new features are developed, Grunt is periodically released to npm. If you do not specify a version number, this build version is not installed at all, and usually they are assigned a build code or alpha/beta/release.
Just like installing the specified version of Grunt, execute
npm install grunt@VERSION --save-dev
VERSION
the version you specify, and npm installs this version of grunt in the project directory and adds it to the devDependencies section of the
package.json
file.
Note that no matter what version you specify, it will be added to the
package.json
file in accordance with the version range marked by the wavy line.
This is harmful,
and when a new version appears in the specified development version, especially an incompatible patch version, it is also installed by npm, which can disrupt your project and make it impossible to compile.
Once this happens,
the most important
thing is to
package.json
file and remove the (tilde) from the version number.
This locks you into a specific development version that you specify.
This technique can also be used to install a developed version of a published Grunt plug-in.
If you need to install the most up-to-date version, and the version of this Grunt or Grunt plug-in is not
published, follow the steps below to specify the git URL
as a dependency and make sure that you specify a specific common SHA (not a branch name) as
commit-ish
This will ensure that your project will always use this exact version of grunt.
This specified git URL can be an official Grunt repository or a fork version.