Error: Cannot find the module. /lib/socket.io '

I had my server working with an earlier version of node.js, npm and socket.io, but after the upgrade I started getting problems with socket.io:

$ node server.js node.js:237 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module './lib/socket.io' at Function._resolveFilename (module.js:333:15) at Function._load (module.js:280:25) at Module.require (module.js:357:17) at require (module.js:373:17) at Object.<anonymous> (/usr/local/lib/node_modules/socket.io/index.js:8:18) at Module._compile (module.js:444:26) at Object..js (module.js:462:10) at Module.load (module.js:351:32) at Function._load (module.js:309:12) at Module.require (module.js:357:17) 

Before the upgrade, I had a symbolic link for socket.io in the node_modules section, pointing to a directory with "centrally installed" with the same name. I recently tried installing socket.io local in my project by running the command:

 npm install socket.io 

which put socket.io in node_modules in my project. At first it seemed strange to me that the error message said "./lib/socket.io", but when I looked at it, I found that the project /node_modules/socket.io/index.js requires socket.io

 module.exports = require('./lib/socket.io'); 

But there is nothing but transport:

 ...project/node_modules/socket.io/lib $ ll total 24 drwxrwxr-x 3 ghbarratt dev 4096 Mar 26 14:38 . drwxrwxr-x 5 ghbarratt dev 4096 Mar 26 15:03 .. -rw-rw-r-- 1 ghbarratt dev 10777 Mar 6 16:37 transport.js drwxrwxr-x 3 ghbarratt dev 4096 Mar 26 14:38 transports 

Should there be another socket.io directory or socket.io.js file under lib? Why does index.js require an internal file that seems to be missing?

Versions:

 node -v v0.7.7-pre npm -v 1.1.12 socket.io@0.9.2 Distributor ID: Ubuntu Description: Ubuntu 10.10 Release: 10.10 Codename: maverick 
+7
source share
1 answer

I hate answering my question, but I understood everything and there were no other answers, so I'm going to add this if it can help someone else.

With a comment by Felix Loener (which I + 1ed) I was pretty sure that I did not receive all the files that I had to have during npm install socket.io . I tried to do apt-get update / upgrade , thinking that I might need an update for tar or something else, but the results remained the same.

I noticed answer 304 at the output of the installation and wondered if there was any cache npm that I should try to clear. I have discovered . I could clear the npm cache with the command: npm cache clean . Clearing the cache finally got me past errors without errors.

Then I started to get the error message: make: node-waf: Command not found , which forces me to reinstall node .

And after all, it worked!

+17
source

All Articles