Using node with

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


Comment actions Permalink

Are you on Windows?

Comment actions Permalink

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:

Comment actions Permalink

That got it working.
Thank you very much!

Comment actions Permalink

You're welcome.

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


Please sign in to leave a comment.