Working on a gruntjs 'Hello World' project, and there doesn't seem to be an optimal place to install a grunt task. Say, for instance, that I want to start compiling coffeescript, I would need the 'grunt-coffee' task installed.
This seems to be the way grunt would like you to do it, and it works.
cd $MY_PROJECT_HOME
npm install grunt-coffee
grunt coffee
However, this adds 7.2mg to my project tree. I don't want to put it in my src control, but if I remove it, grunt will not build my project. I could .gitignore it, but then others that download the repository cannot build without doing the same installations. This also gets a bit messy for CI servers.
cd $MY_PROJECT_HOME
npm install -g grunt-coffee
grunt coffee
Grunt can't find my plugins if I install them this way:
Local Npm module "grunt-coffee" not found. Is it installed?
It's not clear to me why this wouldn't be supported.
Grunt has an api method called loadTasks, which loads tasks locally. I tried pulling down the npms and moving them myself into a custom directory that I referenced here, with no luck. EG
grunt.loadTasks('$SHARED_TASKS_FOR_ALL_MY_GRUNT_PROJECTS/node_modules/grunt-coffee')
and then:
cd $SHARED_TASKS_FOR_ALL_MY_GRUNT_PROJECTS
npm install grunt-coffee
cd $MY_PROJECT_HOME
grunt coffee
Task "coffee" not found. Use --force to continue.
That'd be nice... :)
Sindre below is correct. Option 1 is the way to go, but there is one part missing - the package.json file. So:
node_modules
is .gitignore
-ed.npm install
(note, no arguments) upon a clone or if they add dependencies to the build file.Installing grunt-cli locally js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev . Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .
Run sudo npm install -g grunt-cli (Windows users should omit "sudo ", and may need to run the command-line with elevated privileges). The grunt command-line interface comes with a series of options. Use grunt -h from your terminal to show these options.
First option is the correct way. You don't commit the node_modules folder, but instead just instruct users to do npm install
which fetches all the required dependencies.
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