Running Node.js script on remote interpreter



I am trying to manage a remote project locally in WebStorm. I will run through a few configuration settings with their output and hope that someone can help me understand what is going on and how to fix some of the errors...

Here are, in general, my Run/Debug Configuration settings

Node Interpreter : ssh://me@server:22/remote/path/to/node/bin

Working Directory : /local/dir/with/node/project

Path Mappings : <Project Root> -> /remote/dir/with/node/project


/local/dir/with/node/project and /remote/dir/with/node/project are the same project on a shared directory.

When I run a simple .js script (just console.log('hello world');) in the project I get this in the debugger...

throw err;

Error: Cannot find module '/remote/dir/with/node/project'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

Process finished with exit code 1


If I change Path Mappings to /remote/dir/with/node/project/test.js the program actually runs! But this shows up in the console...

bash: line 0: cd:/remote/dir/with/node/project/test.js: Not a directory
hello world

Process finished with exit code 0

So the cd in bash doesn't work but the script does. Is my path mapping wrong? How do I fix this?

1 comment
Comment actions Permalink

>bash: line 0: cd:/remote/dir/with/node/project/test.js: Not a directory

this error just means that a directory, not a file, is expected as a path mapping.

Did you specify a script to execute (test.js) in your Run configuration? Can you attach a screenshot of your settings?

See what it might look like:


Please sign in to leave a comment.