Debug not stopping on breakpoints in npm-linked modules

Webstorm all of a sudden this week no longer stops at breakpoints in my npm-linked modules.

Breakpoints stop in node_modules that are NOT npm-linked however....so there's definitely something weird about how it reads links.

This is strange because it was working earlier in the week. But as of 2 days ago, Webstorm ignores my npm-linked module's breakpoints.

6 comments
Comment actions Permalink

Have you changed anything since the time it worked? Node.js version, Webstorm version, configuration, etc? Can you recreate the issue in a new project?

0
Comment actions Permalink

Same here, can't debug linked modules any more. NODE 6.10.3

WS:

WebStorm 2017.1.3
Build #WS-171.4424.63, built on May 16, 2017
JRE: 1.8.0_112-release-736-b21 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.5

/Users/okhomenko/.nvm/versions/node/v6.10.3/bin/node --debug-brk=63631 --expose_debug_as=v8debug /Users/okhomenko/test/test-debug/index.js

How to reproduce.

{code}

mkdir test-debug test-linked

cd test-linked

npm init -y -f

echo "module.exports = function () { console.log(123) }" > index.js

npm link

cd ../test-debug

npm init -y -f

npm link test-linked

echo "let log = require('test-linked'); log();" > index.js

{code}

Open in webstorm and try to debug

1
Comment actions Permalink

Known issue, please follow https://youtrack.jetbrains.com/issue/WEB-14424 for updates.

the problem is that you set a breakpoint in `\test-debug\node_modules\test-linked\index.js`, but Node.js resolves an actual module path (`test-linked\index.js`) when the module is loaded.

That means that the breakpoint in the `\test-debug\node_modules\test-linked\index.js` isn't correctly registered, because Node knows nothing about it, but loads `test-linked\index.js` instead.

And for WebStorm these are 2 different files (see https://youtrack.jetbrains.com/issue/IDEA-85774, https://youtrack.jetbrains.com/issue/WEB-25407 and other linked tickets)... and, moreover, the actual file is out of project scope...

In general, WebStorm doesn't play well with symlinks, they cause various issues, for example, fsnotifier tool we use to synchronize the IDE virtual file system with external changes doesn't support them (https://youtrack.jetbrains.com/issue/IDEA-65174). Cyclic links can also cause performance issues when indexing. So I'd suggest to avoid using them if possible

-1
Comment actions Permalink

Actually, I resolved this by running node with --preserve-symlinks

9
Comment actions Permalink

Thanks Iyobo. --preserve-symlinks works fine. Another approach I've found is to add linked module as External Library

0
Comment actions Permalink

Thanks Iyobo Eki, that solution worked for me.

0

Please sign in to leave a comment.