Webpack-dev-server: issues running Visual Studio Code Debugger with webpack-dev-server

Created on 10 Feb 2017  路  5Comments  路  Source: webpack/webpack-dev-server

I have an issue with getting webpack-dev-server to run from the debugger in Visual Studio Code on Windows 10. The project runs perfectly on Linux and Mac, but for some reason it errors out on windows. It also works fine from VSC's tasks implementation, and from the command line on _all platforms_. Thank you in advance for your help.

Please note I have posted this issue in two other places in case this is not a bug in webpack-dev-server:

http://stackoverflow.com/questions/42138058/webpack-dev-server-not-working-from-debugger-on-windows-10

https://github.com/Microsoft/vscode/issues/20350

The error I get on windows is the following:

Cannot launch program 'c:devel\src\MyWebKitnode_modules.bin\webpack-dev-server'; setting the 'outFiles' attribute might help.

My current setup is:

VSC: 1.9.1
OS: Windows 10 Anniversary
webpack: 2.2.1
webpack-dev-server: 2.3.0

My configuration launch.json file for VSC:

{
  "version": "0.2.0",
  "configurations": [
    {
        "name": "Launch",
        "type": "node",
        "request": "launch",
        "program": "${workspaceRoot}/node_modules/.bin/webpack-dev-server",
        "args": [
            "-d",
            "--config",
            "webpack/default.js"
        ],
        "outFiles": [
            "${workspaceRoot}/build/*"
        ],
        "stopOnEntry": false,
        "cwd": "${workspaceRoot}",
        "runtimeExecutable": null,
        "runtimeArgs": [],
        "env": {
            "NODE_ENV": "development"
        },
        "console": "internalConsole",
        "sourceMaps": true
    }
  ]
}

Most helpful comment

@kryptonianson ... recognize this is an old, closed thread. That error message from VSCode and is super unclear.

Chances are that Windows doesn't like trying execute webpack-dev-server in the node_modules/.bin. Try changing the "program" option to node_modules/webpack-dev-server:

        {
            "type": "node",
            "request": "launch",
            "name": "webpack-dev-server",
            "program": "${workspaceRoot}/node_modules/webpack-dev-server/bin/webpack-dev-server.js",
            "cwd": "${workspaceFolder}"
        }

Leaving this hear in case it helps someone in the future.

All 5 comments

Sorry but as far as I know this can't be an issue in webpack-dev-server. It works perfectly fine in the console, so I don't see how it not running in VSC is an issue of webpack-dev-server. In Microsoft/vscode#20350 they never said it was an issue in WDS?

I agree with your comment, but since I am getting nowhere I thought it worth a shot here. Also, no one has said it was due to WDS, I was just trying to do my due diligence. I appreciate your response.

I'm going to close this since there is nothing I can do here...

@kryptonianson ... recognize this is an old, closed thread. That error message from VSCode and is super unclear.

Chances are that Windows doesn't like trying execute webpack-dev-server in the node_modules/.bin. Try changing the "program" option to node_modules/webpack-dev-server:

        {
            "type": "node",
            "request": "launch",
            "name": "webpack-dev-server",
            "program": "${workspaceRoot}/node_modules/webpack-dev-server/bin/webpack-dev-server.js",
            "cwd": "${workspaceFolder}"
        }

Leaving this hear in case it helps someone in the future.

I occur the same problem. After tried different ways, the follow config is working.
launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      // "program": "cd ${workspaceFolder};npm run dev"
      "program": "${workspaceFolder}\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js",
      "args": [
        "-d",
        "--inline",
        "--progress",
        "--config",
        "build\\webpack.dev.conf.js"
      ],
      "cwd": "${workspaceFolder}"
    }
  ]
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

daryn-k picture daryn-k  路  3Comments

movie4 picture movie4  路  3Comments

eyakcn picture eyakcn  路  3Comments

Jack-Works picture Jack-Works  路  3Comments

da2018 picture da2018  路  3Comments