0

I am trying to install node-debugger and can't install with out sudo. Using sudo gets me some unexpected sideeffects, so want to install with out sudo. Following is the error trace

 $  npm install -g node-inspector
npm http GET https://registry.npmjs.org/node-inspector
npm http 304 https://registry.npmjs.org/node-inspector
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/node-inspector'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/node-inspector']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/node-inspector',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/node-inspector',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.8.0-35-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "node-inspector"
npm ERR! cwd /home/santhosh/dev/scaleqa/mean_tut/mean_io_original/scaleqaApp
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! path /usr/local/lib/node_modules/node-inspector
npm ERR! fstream_path /usr/local/lib/node_modules/node-inspector
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/node-inspector'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/santhosh/dev/scaleqa/mean_tut/mean_io_original/scaleqaApp/npm-debug.log

npm ERR! not ok code 0
raju
  • 4,788
  • 15
  • 64
  • 119
  • 2
    It's recommended that [`sudo` should be used with `-g`/`--global` installs](https://github.com/npm/npm#permissions-when-using-npm-to-install-other-stuff). So, what unexpected side effects does using it cause? Though, if really needed, you can follow the early advice of [taking ownership of the install directory​](http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo). – Jonathan Lonowski May 03 '14 at 18:55

2 Answers2

0

You have to use sudo; this is because when you install globally, NPM creates links from your bin folder(s) to scripts that run node and the specified scripts from the packages (making node-inspector somescript.js really run node /path/to/inspector/node_inspector.js somescript.js.

Those bin folders are protected to those who are not super users, therefore sudo must be used to elevate your access level and allow npm to write to those directories.

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
0

You are being asked for sudo because you are installing the npm module globally i.e you are using -g and they are stored in bin which can be accessed by sudo user !

if you do not use -g i.e you install it locally it wont ask for sudo permission!

vipulsodha
  • 624
  • 1
  • 9
  • 27