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 ...

debugger stack trace

(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.

+3


source to share


1 answer


I got the same problem. The solution is to use intellij Webstorm instead of intellij. It doesn't have this problem and is possibly downloading a .js file from a remote server (I'm not sure about this). But I solved the problem this way. Hope this helps.



0


source







All Articles