Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM error when installing globally even when directories are writable

Tags:

node.js

npm

i have this error when try to install coffee-script using this command:

npm install -g --verbose coffee-script opal

these are the error message:

npm ERR! Error: EACCES, symlink '../lib/node_modules/coffee-script/bin/coffee'
npm ERR!  { [Error: EACCES, symlink '../lib/node_modules/coffee-script/bin/coffee']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '../lib/node_modules/coffee-script/bin/coffee' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm info postuninstall [email protected]
npm ERR! Error: EACCES, symlink '../lib/node_modules/opal/bin/opal-node'
npm ERR!  { [Error: EACCES, symlink '../lib/node_modules/opal/bin/opal-node']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '../lib/node_modules/opal/bin/opal-node' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

the folder /usr/local/bin and /usr/local/lib/node_modules are owned and writable by current user, and i do not want to run that npm command using root, how to know which folder that the npm tried to make a symlink to?

i'm using npm 1.2.9-1chl1~quantal1 and nodejs 0.8.19-1chl1~quantal1

like image 896
Kokizzu Avatar asked Feb 09 '13 09:02

Kokizzu


People also ask

Why npm is not installing?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.


3 Answers

your node installation uses system directories. Use sudo when using -g

sudo npm install -g --verbose coffee-script opal
like image 114
Pascal Belloncle Avatar answered Oct 09 '22 17:10

Pascal Belloncle


You can chown NPM's bin to your user name with this one liner to solve this problem:

$ chown -R `whoami` `npm -g bin`
like image 23
Mohsen Avatar answered Oct 09 '22 16:10

Mohsen


ah, using this command:

npm -g bin

it would output something like this:

/usr/bin # this is the folder nodejs wanted to write..

then you may chmod or chown it so it can be written for installation.

like image 4
Kokizzu Avatar answered Oct 09 '22 17:10

Kokizzu