In this section, the installation of Grunt and any potential setup issues will be addressed.
There are no use cases for which Grunt should be installed globally. The configuration of Grunt and its associated plugins will be provided in each of the projects within this book.
When starting a new project, you can install Grunt within the project directory by issuing the following command:
npm install grunt
Any Grunt plugins that will be used in the projects of this book will also be installed through npm. The installation steps for each plugin will be included in each project.
In this section, various troubleshooting errors will be explored and diagnosed.
This error is typically caused by the lack of grunt-cli
, the command-line interface for Grunt. As per the best practices suggested by the Node community itself, Grunt is intended to be installed locally for each project. Any command-line tools such as grunt-cli
are intended to be installed globally. Thus, you should issue a global installation of grunt-cli
in order to fix this problem, as shown in the following command:
npm install -g grunt-cli
When you receive this error, it is because a local Grunt binary cannot be found within the Node modules of the project. This typically occurs when grunt-cli
is installed but Grunt is uninstalled or missing.
To fix this problem, just reinstall Grunt locally, ensuring that it is added to your package.json
file by passing the --save-dev
flag, as shown in the following command:
npm install --save-dev grunt