IntelliJ IDEA does not map to nodejs module JavaScript source loaded via require ()
I am trying to set up an environment for developing a NodeJS application using IntelliJ IDEA using the NodeJS plugin (I believe it works the same in WebStorm).
I have no problem running simple applications, but as soon as I start with require()
my own module, I have a problem: IDEA does not understand what is the source file of the required module and all the stacktraces for breakpoints inside my module look like this:
unknown:0 // (this is my require()d module, but wrapped in an IIFE by nodejs module loader)
Module._compile(), module.js:460
Module._extensions..js(), module.js:478
...
(since no source code received I end up in my module with Step Inside / Step Over from my main file)
The code is really basic:
var m = require("./modulejs.js");
var test = new m.Test("Test");
test.printname();
and modulejs.js
looks like this:
var Test = (function () {
function Test(name) {
this.name = name;
}
Test.prototype.printname = function () {
console.log("Test name: " + this.name); // I'm on this line in the screenshot above
};
return Test;
})();
exports.Test = Test;
The problem seems to be so basic to me that I am quite sure that it is some misconfiguration on my side.
I am on Windows 7 using IDEA 14.1.4 and NodeJS plugin 141.1509, both of which seem to be the latest stable releases. I also tried different versions of nodejs: 0.11.16 and 0.12.5 with the same behavior in both versions. It works from 0.10.36 as expected.
source to share