Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt plugins are not installed in current location

I'm working with Mac OS X 10.7.5 and I'm using Grunt to concate some js files and minify them. Now I want to also minify my css files. As grunt does not provide any functionality I wanted to install a grunt plugin for that. According to the instructions i have to cd into my projects root folder and install the plugin with npm. So I did the following:

cd <PROJECT_ROOT>
npm install grunt-contrib-css

The instructions for the plugin are here: https://npmjs.org/package/grunt-contrib-mincss The I opened my grunt.js file and added

grunt.loadNpmTasks('grunt-contrib-mincss');

But when I try to run grunt I just get

Local Npm module "grunt-contrib-mincss" not found. Is it installed?
<WARN> Task "mincss" not found. Use --force to continue. </WARN>

The installation works without any problem and npm ls does list the module.

Any ideas what I have done wrong? Many Thanks!

UPDATED

When I cd into a project like so

cd ~/Sites/path/to/project

and then install the plugin

sudo npm install grunt-contrib-mincss

the module is actually installed in

~/node_modules/grunt-contrib-mincss

I could hard copy the files into my projects root directory (which works) but it's kind of strange isn't it?

UPDATE 2 I've updated node and tried it again. Below is the console output.

me:~ Fritz$ node -v
v0.8.10
me:~ Fritz$ npm -v
1.1.62
me:~ Fritz$ mkdir ./Sites/npm-test
me:~ Fritz$ cd ./Sites/npm-test/
me:npm-test Fritz$ sudo npm install grunt-contrib-mincss
Password:
npm http GET https://registry.npmjs.org/grunt-contrib-mincss
npm http 304 https://registry.npmjs.org/grunt-contrib-mincss
npm http GET https://registry.npmjs.org/gzip-js
npm http GET https://registry.npmjs.org/clean-css
npm http GET https://registry.npmjs.org/grunt-contrib-lib
npm http 304 https://registry.npmjs.org/gzip-js
npm http 304 https://registry.npmjs.org/clean-css
npm http 304 https://registry.npmjs.org/grunt-contrib-lib
npm http GET https://registry.npmjs.org/crc32
npm http GET https://registry.npmjs.org/deflate-js
npm http GET https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/deflate-js
npm http 304 https://registry.npmjs.org/crc32
npm http 304 https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/wordwrap
[email protected] ../../node_modules/grunt-contrib-mincss
├── [email protected]
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected])

Why is the plugin installed outside? Or is there a way to define the actual location where it is installed?

like image 731
F Lekschas Avatar asked Feb 19 '23 01:02

F Lekschas


1 Answers

I had a similar issue on Ubuntu 12.04 for the module grunt-jasmine-task (same error message as above). This solved the issue for me:

  1. Manually create the folder node_modules in the root of the project.
  2. Run npm install grunt-jasmine-task again.
like image 86
Ludder Avatar answered Mar 05 '23 02:03

Ludder