Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use remote node_modules (inside container) on WebStorm?

I installed all npm dependencies inside to the container. So I don't want to install dependencies to my host machine. Everything is okay, it works. But there is a problem with Webstorm.

It says "Unresolved function" for npm dependencies. How to fix that problem? How can I say "Hey webstorm, node_modules directory is inside the container :)"

like image 494
selahattinunlu Avatar asked Dec 18 '18 15:12

selahattinunlu


2 Answers

WebStorm expects node_modules to be located in the project folder.

You can try setting up NODE_PATH in Node.js run configuration template: Run | Edit Configurations..., expand Templates node, select Node.js configuration, specify NODE_PATH in Environment variables field

Please see comments in https://youtrack.jetbrains.com/issue/WEB-19476.

But I'm not sure it will work for modules installed in container...

like image 155
lena Avatar answered Sep 21 '22 23:09

lena


Even though you expose the container's node_modules folder it's likely to not work as expected because npm dependencies are built according their host environment, which will not be the same as your local dev machine.

This statement applies even stronger if you want to run some CLI developments tools - which sometimes are compiled binary files.

like image 29
enapupe Avatar answered Sep 17 '22 23:09

enapupe