简体   繁体   中英

Run and Debug Nodejs in WSL 2 with Intellij IDEA on Windows 10

Intellij IDEA(version 2018.03) is installed on Windows. The application is developed in NodeJs.

Project source code stored in git on Windows.

I am able to point Intellij IDEA to use the Nodejs interpreter from WSL2.

But when I debug the application the project doesn't initiate (ie there is nothing running on the default port 3000 which I have specified for app.). Nothing resolves on localhost:3000/myRuote

If I revert to wsl1 then everything works fine, on debug the process starts and localhost:3000/myRuote resolves. Am I missing something or do I need to do some different setting so that project starts on the default port.

Note: I Upgraded from wsl1 to wsl2, wondering if that was the reason.

http://localhost:3000 will point at your windows system.

in a wsl2 terminal, run the following command:

hostname -I

it will give you the ip for your wsl os. Beware it changes everytime it is restarted. use that ip instead of localhost, it should work.

if you are using webpack dev server, you will want to start your app like so:

webpack serve --mode development --host 172.18.47.92

where the host ip is the ip for your wsl2 instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM