Using node with socket.io

I am trying to develop an application using node with socket.io.  Using just node I can compile and debug just fine, but when I try to use the socket.io module I get an error stating "Cannot find module 'socket.io'".  Any ideas on what I need to do to configure Webstorm to see this module?

Thanks

0
5 comments

Are you on Windows?

0

When playing with node recently I've found that globally installed modules (e.g. c:\Program Files (x86)\nodejs\node_modules\mysql) cannot be found, as node searches modules in a couple locations but not in the right one:
from Module.js:

Module._initPaths = function() {
  var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];

  if (process.env['HOME']) {
    paths.unshift(path.resolve(process.env['HOME'], '.node_libraries'));
    paths.unshift(path.resolve(process.env['HOME'], '.node_modules'));
  }

  if (process.env['NODE_PATH']) {
    var splitter = process.platform === 'win32' ? ';' : ':';
    paths = process.env['NODE_PATH'].split(splitter).concat(paths);
  }

  modulePaths = paths;

  // clone as a read-only copy, for introspection.
  Module.globalPaths = modulePaths.slice(0);
};


This '..', '..' looks like it asumes Unix paths (/usr/local/bin, usr/lib etc.)

Right now I workarounded this by adding NODE_PATH to my run configuration params:
node.png

0

That got it working.
Thank you very much!

0

You're welcome.

Although I'm not sure if I should report a bug to Node devs or somethng.

0

Please sign in to leave a comment.