0

I am trying to install Grunt (on Windows).

The documentation (http://gruntjs.com/getting-started) says to install grunt-cli and explains that this is not the Grunt task runner but just the program to allow the grunt command to be run from any folder. Ok. Fine. I've done that. My next question is; how to install the Grunt task runner. The implication of the docs is that this will be installed locally in my project directory.

How do I do that?

The project already has a Gruntfile.js and a package.json & works on another machine. I'm just trying to get it run locally.

Specifically I get this message:

"... a Gruntfile wasn't found or Grunt hasn't been installed locally to your project"

Thanks

--Justin Wyllie

1 Answer 1

0

npm install --save-dev grunt to install it just like any module and add it to your package.json file as a development dependency.

grunt may also already be listed as a dependency, in which case you may just need to run npm install to install all dependencies.

4
  • It could also be useful to note that since the project works on another machine, Grunt is probably already listed as a dev dependency in his package.json. If that's the case, Grunt and all the project's other npm dependencies can be installed locally with just npm install
    – jbll
    Feb 3, 2014 at 17:56
  • Ok. It was and just doing npm install worked. Thanks. .... In the package.json there is field 'main' with the value 'grunt.js'. However grunt is using Gruntfile.js. (grunt.js is hanging around from a previous project and I can get rid of it). But what is that 'main' field about?
    – user911625
    Feb 3, 2014 at 18:56
  • Also, sorry, does the directory node-modules need to be there? Can this go in the main system location where grunt-cli is?
    – user911625
    Feb 3, 2014 at 18:57
  • Generally each node project has its own node_modules folder for it's specific dependency versions. main defines the file that is loaded when you require(...) a module, so in this case requiring the module would return the exports object from grunt.js. Feb 3, 2014 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.