0

I'm trying to install grunt.js. As the official docs says, I should run

npm install -g grunt-cli

as root (I'm using ubuntu linux). I'm trying - and I get the following error:

$ sudo npm install -g grunt-cli
npm ERR! sudon't! 
npm ERR! sudon't! Running npm as root is not recommended!
npm ERR! sudon't! Seriously, don't do this!
npm ERR! sudon't!
npm ERR! couldn't read package.json in .
npm ERR! Error installing .
npm ERR! Error: ENOENT, No such file or directory 'package.json'
npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
npm ERR! or email it to <npm-@googlegroups.com>
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

Can someone please explain:

[1] why npm says `sudon't` and grunt docs says `do sudo`? And what is it all about?
[2] I want to install the grunt as a tool. Why does the message complains about missing package.json which is project-dependent (and I don't want to run grunt on any project, I want to install it globally first)?
[3] what can I do to make it install successfully?
ducin
  • 25,621
  • 41
  • 157
  • 256
  • What node version are you using? Seems like this has been fixed a long time ago: http://stackoverflow.com/questions/4938592/how-why-does-npm-recommend-not-running-as-root – jgillich May 07 '13 at 18:42
  • 0.4.9 from oneiric ocelot packages. Well, I don't quite understand what is it all about, but I just want to install `grunt.js`... – ducin May 07 '13 at 18:48

1 Answers1

0

The solution was quite tricky... I'm using ubuntu oneiric ocelot, which was still maintained one week ago (it's not that old). I installed node.js through default ubuntu packages and it turned out to be the problem - I got 0.4.9 version installed, which seems to be old, odd and strange (I had no experience with node.js before). I removed it and followed instructions from https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager - added remote package repository and installed node.js from there. Now I've got a shiny 0.10.5 with sudo npm install working perfectly fine with no complaints.

ducin
  • 25,621
  • 41
  • 157
  • 256