I am new to node, npm, socket.io. Found many guides that are fairly useful, but I am encountering some errors which I don’t understand the cause, hopefully you can help me out.
npm install socket.io -g
returns …
npm http GET https://registry.npmjs.org/socket.io
npm http 304 https://registry.npmjs.org/socket.io
npm ERR! error installing socket.io@0.9.4
npm ERR! error rolling back socket.io@0.9.4 Error: EACCES, unlink '/usr/local/lib/node_modules/socket.io/.npmignore'
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/socket.io/.npmignore'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR!
npm ERR! System Darwin 10.8.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "socket.io" "-g"
npm ERR! cwd /Users/Kinglee
npm ERR! node -v v0.6.14
npm ERR! npm -v 1.1.0-beta-4
npm ERR! path /usr/local/lib/node_modules/socket.io/.npmignore
npm ERR! code EACCES
npm ERR! message EACCES, unlink '/usr/local/lib/node_modules/socket.io/.npmignore'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Kinglee/npm-debug.log
however when i did npm install socket.io, there was no error, everything was fine.
Sorry forget to add this info here …
I actually tried sudo npm install socket.io and it installed without error but when i try to cd ~/node_modules, I don’t see socket.io, this cause 'socket.io not found' error when i try to do require('socket.io') as I follow this tutorial here (http://blog.koostudios.com/?p=470)
Kind of confused fellow here :/
The most important portion is:
This means you do not have permission to delete this file.
I assume this means you ran the command as your standard user account, which will not have write permission into
/usr/.Prepend
sudoto your command to re-run the command with administrator privileges:Your local configuration may not have
/usr/local/lib/node_modules/innode‘s default module loading locations. The module loading path is controlled via theNODE_PATHenvironment variable (before startingnode) or therequire.pathsvariable (oncenodeis running). Because I prefer to keep local configuration separated from the program, I’d prefer to set the environment variable to modify paths, though the other mechanism may be useful for long-lived applications that must remain up even when the environment changes. (This is definitely an advanced use.)To change the
NODE_PATHvariable for a single instance,shand its derivatives will let you simply addNODE_PATH=/pathbefore the command. For example, change:to
If you have multiple directories, use the standard
:-separated directories, just as you would forPATH:To make this persistent, use the shell’s
exportbuiltin to export the value of theNODE_PATHvariable to all children and place the modification in your shell’s start up files, such as~/.bashrc:This will take effect in all new shells automatically. You can
sourcethis file into currently-running shells if you don’t wish to restart them: