node.jsgruntjsgrunt-contrib-watchgoogle-api-nodejs-clientgrunt-usemin

how to set grunt variable env path


I am trying to set grunt for my node.js project and I have followed below steps:
1)I have installed node.js and it is working fine.
2)Installed git.
3)Installed grun by running: npm install -g grunt-cli.

C:\Users\user\Downloads\bpost-gs-api-1.1.1>npm install -g grunt-cli
C:\Users\user\AppData\Roaming\npm\grunt -> C:\Users\891153\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt
C:\Users\user\AppData\Roaming\npm
`-- grunt-cli@1.2.0

Now I have run the cmd grunt -version, I got below error:

grunt is not recognized as an internal or external command, operable program or batch file.

Can you please help me to set up grunt for my project. How to setup variable env and how to setup path etc.

Appreciate your help


Solution

  • https://gruntjs.com/getting-started

    In order to get started, you'll want to install Grunt's command line interface (CLI) globally. You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to do this.

    npm install -g grunt-cli
    

    This will put the grunt command in your system path, allowing it to be run from any directory. Note that installing grunt-cli does not install the Grunt task runner! The job of the Grunt CLI is simple: run the version of Grunt which has been installed next to a Gruntfile. This allows multiple versions of Grunt to be installed on the same machine simultaneously.

    start from reading this: https://gruntjs.com/installing-grunt

    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.

    for better understood on how to start setup a grunt project: https://gruntjs.com/getting-started#preparing-a-new-grunt-project

    A typical setup will involve adding two files to your project: package.json and the Gruntfile. package.json: This file is used by npm to store metadata for projects published as npm modules. You will list grunt and the Grunt plugins your project needs as devDependencies in this file. Gruntfile: This file is named Gruntfile.js or Gruntfile.coffee and is used to configure or define tasks and load Grunt plugins. When this documentation mentions a Gruntfile it is talking about a file, which is either a Gruntfile.js or a Gruntfile.coffee.