Work on the gruntjs project "Hello World", and there seems to be no optimal place to install the grunt task. Let's say, for example, that I want to start compiling coffeescript, I need the "grunt-coffee" task.
Option 1: install it directly in my src tree
It seems that the way you want to do this and it works.
cd $MY_PROJECT_HOME npm install grunt-coffee grunt coffee
However, this adds 7.2mg to my project tree. I do not want to put it in my src control, but if I remove it, I wonβt grunt to build my project. I could .gitignore it, but then the others that load the repository cannot build without performing the same installations. This is also a bit confusing for CI servers.
Option 2: Install It Globally
cd $MY_PROJECT_HOME npm install -g grunt-coffee grunt coffee
Grunt cannot find my plugins if I install them this way:
Local Npm module "grunt-coffee" not found. Is it installed?
I do not understand why this is not supported.
Option 3: install them somewhere else?
Grunt has an api method called loadTasks that loads tasks locally. I tried to pull out npms and transfer them to a special 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.
Option 4: Grunt in its loadNpmTasks call pulls dependencies for me in the .grunt directory somewhere
That would be good...:)
EDIT
The syndrome below is true. Option 1 is the path, but one part is missing - the package.json file. So:
- Add the package.json file and put all your dependencies there .
- Make sure
node_modules .gitignore -ed. - In your README, give some instructions to run
npm install (note no arguments) on the clone or if they add dependencies to the build file.
javascript gruntjs
Roy truelove
source share