I'm new to Grunt and I'm having trouble setting up a project with new plugins.
So far I have:
This all works great, however I want to use a different uglify plugin so, still in the 'test' directory, I run:
npm install uglify-js --save-dev
As I'm not using the global flag, the plugin downloads to test/node_modules directory as expected, existing at test/node_modules/uglify-js. The package.json file has been updated with the additional dependency:
"uglify-js": "^2.4.15"
I then edit Gruntfile.js, adding
grunt.loadNpmTasks('uglify-js');
And change
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
To
grunt.registerTask('default', ['concat', 'uglify-js']);
I run
npm install
to ensure all dependencies are downloaded, but now when I run the grunt task I get this error:
Local Npm module "uglify-js" not found. Is it installed?
Warning: Task "uglify-js" not found. Use --force to continue.
Anyone have any idea what I'm doing wrong?
Mac OS X 10.8.5, Node v0.10.32
If you want to use UglifyJS whit grunt, you should use grunt-contrib-uglify. Install it with:
npm install grunt-contrib-uglify --save-dev
enable it inside your Gruntfile.js:
grunt.loadNpmTasks('grunt-contrib-uglify');
and run your task:
grunt uglify
See the docs for more information.