Error when using socket.io

nodejs

#1

I’m trying to run something on cloud9 that requires socket.io, but it keeps on giving me the following error:
module.js:338
throw err;
^
Error: Cannot find module 'socket.io
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/var/lib/cloud9/projects/server.js:4:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)

Process exited with code: 1

I’ve tried installing socket.io some times but it just won’t be recognized by Cloud9 server. I’ve installed it via cmd, globally. Can someone tell me how to fix this?
Tks!


#2

Does your package.json file show a socket.io version?


#3

The global install path is not in the default package lookup path, so node won’t find it. The global option is for cli programs, not for this usage. You should install it locally instead.


#4

No,it doesn’t. Should it?


#5

okay, but then when I try on cloud9 cd, this happens:

root@beaglebone:/var/lib/cloud9# npm upgrade
root@beaglebone:/var/lib/cloud9# npm update
root@beaglebone:/var/lib/cloud9# sudo npm install socket.io
npm ERR! Linux 4.4.30-ti-r64
npm ERR! argv “/usr/bin/node” “/usr/bin/npm” “install” "socket.io"
npm ERR! node v0.12.17
npm ERR! npm v2.15.1
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’

npm ERR! Please include the following file with any support request:
npm ERR! /var/lib/cloud9/npm-debug.log
root@beaglebone:/var/lib/cloud9# npm install socket.io
npm ERR! Linux 4.4.30-ti-r64
npm ERR! argv “/usr/bin/node” “/usr/bin/npm” “install” "socket.io"
npm ERR! node v0.12.17
npm ERR! npm v2.15.1
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’

npm ERR! Please include the following file with any support request:
npm ERR! /var/lib/cloud9/npm-debug.log
root@beaglebone:/var/lib/cloud9#

What should I do?