Reputation: 26437
I'm starting my work on a JS project, where I want to use bower, grunt and so on. qunit-sinon
is the main directory of my project:
tducin@home:~/Development/qunit-sinon (grunt)$ ll
razem 192
drwxrwxr-x 5 tducin tducin 4096 sie 24 11:45 ./
drwxrwxr-x 3 tducin tducin 4096 sie 23 18:00 ../
drwxrwxr-x 5 tducin tducin 4096 sie 23 18:18 bower_components/
-rw-rw-r-- 1 tducin tducin 458 sie 23 18:15 bower.json
drwxrwxr-x 8 tducin tducin 4096 sie 24 11:42 .git/
-rw-rw-r-- 1 tducin tducin 552 sie 23 20:46 .gitignore
-rw-rw-r-- 1 tducin tducin 1148 sie 24 11:41 Gruntfile.js
-rw-rw-r-- 1 tducin tducin 485 sie 23 18:26 index.html
-rw-rw-r-- 1 tducin tducin 1079 sie 23 20:45 LICENSE
drwxrwxr-x 4 tducin tducin 4096 sie 24 11:46 node_modules/
-rw-rw-r-- 1 tducin tducin 140356 sie 24 11:45 npm-debug.log
-rw-rw-r-- 1 tducin tducin 346 sie 24 11:44 package.json
-rw-rw-r-- 1 tducin tducin 324 sie 23 18:30 README.md
-rw-rw-r-- 1 tducin tducin 1402 sie 24 11:00 tests.js
I've got following installed globally: node/npm, bower, grunt-cli. I used grunt-init gruntfile
to initialize my Gruntfile.js
. The content of my package.json
is:
tducin@home:~/Development/qunit-sinon (grunt)$ cat package.json
{
"engines": {
"node": ">= 0.10.0"
},
"repository": {
"type": "git",
"url": "git://github.com/tkoomzaaskz/qunit-sinon"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-qunit": "~0.5.2",
"grunt-contrib-watch": "~0.6.1"
}
}
Now I want to run npm install
to install all missing modules (few grunt plugins there were automatically added to Gruntfile.js), tut then I get following error:
tducin@home:~/Development/qunit-sinon (grunt)$ npm install
npm ERR! Error: EACCES, mkdir '/home/tducin/.npm/underscore/1.6.0'
npm ERR! { [Error: EACCES, mkdir '/home/tducin/.npm/underscore/1.6.0']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/tducin/.npm/underscore/1.6.0',
npm ERR! parent: 'jshint' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.13.0-34-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/tducin/Development/qunit-sinon
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! path /home/tducin/.npm/underscore/1.6.0
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/tducin/.npm/underscore/1.6.0'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/tducin/Development/qunit-sinon/npm-debug.log
npm ERR! not ok code 0
npm want to install globally - that's why he wants to have administrator privileges. But it's not what I want to do.
I'm pretty sure that the reason for this error is very obvious, yet, I don't know it. Please explain me why is npm trying to install in /home/tducin/.npm
(global) instead of my local project node_modules
directory.
Upvotes: 0
Views: 498
Reputation: 26437
Ok, after some time I ran into similar problems. In fact I was the owner of the ~/.npm
directory itself, not the root. But my problem was that some of the content of ~/.npm
was mine and some was root's. That's why installing some modules worked and installing others failed. It probably happened because of me using npm install in wrong way.
Following command fixed the issue:
sudo chown -R tducin:tducin ~/.npm
Upvotes: 0
Reputation: 417
I can't comment due to rep so...
Is there anything in the debug log?
/home/tducin/Development/qunit-sinon/npm-debug.log
It doesn't look like it's trying to install globally as global modules are usually in /usr/local/lib/node_modules
or /usr/lib/node_modules
Please post the result of:
ls -l -a /home/tducin/ | grep npm
As the .npm folder may have been created as root
Upvotes: 1