Configuring VSC launch.json to start the webpack-dev server

I am trying to get Visual Studio Code to run the webpack-dev-server command, but no matter what configuration I use in launch.json, I get an error.

My current launch.json looks like this:

{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "node", "request": "launch", "program": "./node_modules/.bin/webpack-dev-server.cmd", "stopOnEntry": false, "args": ["-d --hot --inline"], "cwd": ".", "runtimeExecutable": null, "runtimeArgs": [], "env": { "NODE_ENV": "development" }, "externalConsole": false, "sourceMaps": true, "outDir": "null" }, { "name": "Attach", "type": "node", "request": "attach", "port": 5858 } ] } 

Current error:

 cannot launch program 'c:\ftct\node_modules\.bin\webpack-dev-server.cmd'; setting the 'outDir' attribute might help 

I tried setting outDir to some value, but it complains about setting this attribute nonetheless.

Any ideas? This is what seems like the last hurdle when porting from Visual Studio 2015 to Visual Studio Code!

+5
source share
2 answers

Someone came across this, I was able to get it to work with this:

 { "type": "node", "request": "launch", "name": "Start JS", "program": "${workspaceFolder}/node_modules/webpack-dev-server/bin/webpack-dev-server", "args": [ "--config", "webpack.javascript.js", "--hot", "--progress" ], "console": "internalConsole", "internalConsoleOptions": "openOnSessionStart" }, 

This uses the webpack.javascript.js custom configuration file. If you use the default, you can probably remove the first two arguments. Formatting is a small message in the console at startup, but it works, including hitting breakpoints.

This is in the latest VS code at the time of this writing.

+1
source

Args are wrong. They should be like this:

  "args": ["-d", "--hot", "--inline", "--outDir", "."] 
0
source

Source: https://habr.com/ru/post/1237775/


All Articles