Npm install failing

I will start by saying that I have no experience working in a terminal or with node.js.

The courer went on vacation, and I try to follow the instructions that he left to create his application on our demo server. I can get everything that works locally, but I ran into problems on the server installing the socket.io module.

Installed python, installed nodejs are both successful. But then I issue the command:

npm install -g socket.io 

And I get the output:

 npm http GET https://registry.npmjs.org/socket.io npm http 304 https://registry.npmjs.org/socket.io npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/socket.io' npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/socket.io'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/socket.io', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/socket.io', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ 'DirWriter._create (/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:297:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Linux 2.6.32-279.el6.x86_64 npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "socket.io" npm ERR! cwd /home/qa npm ERR! node -v v0.8.16 npm ERR! npm -v 1.1.69 npm ERR! path /usr/local/lib/node_modules/socket.io npm ERR! fstream_path /usr/local/lib/node_modules/socket.io 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/socket.io' npm ERR! fstream_stack DirWriter._create (/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:297:15) npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/qa/npm-debug.log npm ERR! not ok code 0 

The account I work for must have administrator privileges. Taking a walk around, I found several suggestions, but no one worked for me. Tried the preending command with sudo, but get:

 [qa@umr-demo ~]sudo npm install -g socket.io [sudo] password for qa: sudo: npm: command not found 
+8
linux bash shell npm
source share
2 answers

I have the same error if it is not privileged, so I have to use sudo when using the -g flag

If sudo does not recongize npm, you can try:

  • full npm routing

     $ sudo $(which npm) install -g socket.io 
  • saving environment with the -E flag

     $ sudo -E npm install -g socket.io 

Update:

Please note that it is recommended to use the -g flag only for executable files and install locally (without a flag) the libraries that require d in your code. Copying executable files requires /usr/bin privileges or, in your case, /usr/local/bin

Please note that on the socket.io website the -g flag is not specified for the install command;)

More details: http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/

+20
source share

If you are on Arch Linux, check out the npm2arch package in AUR. This will allow you to install npm packages using pacman.

Example:

 npm2archinstall socket.io 
0
source share

All Articles