Vscode: Cannot start debugging electron app on MacOS

Created on 10 Jul 2020  路  12Comments  路  Source: microsoft/vscode




  • VSCode Version: 1.47.0
  • OS Version: MacOS 10.14.6
  • Node version: 10.x

Steps to Reproduce:

  1. Try to launch an electron app with debugging
  2. The launch fails because it cannot find part of a path.
env 'NODE_OPTIONS=--require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" ' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/var/folders/nt/zdymwv25293f4np_gk2fbwncqbxqtl/T/node-cdp.25357-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/usr/local/bin/node","onlyEntrypoint":false,"fileCallback":"/var/folders/nt/zdymwv25293f4np_gk2fbwncqbxqtl/T/node-debug-callback-11a6774a17fd2a40"}' /Users/lini/Documents/Github/app/node_modules/.bin/electron --enable-logging ./main.js --param1=http://localhost:1234/ --param2=http://localhost:4200 
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Applications/Visual'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
    at preloadModules (internal/bootstrap/node.js:602:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
bash-3.2$ 

Launch.json for the command:

{
      "name": "Debug Electron",
      "type": "node",
      "request": "launch",
      "program": "${workspaceFolder}/src/main.ts",
      "stopOnEntry": false,
      "args": [
        "--param1=http://localhost:1234/",
        "--param2=http://localhost:4200"
      ],
      "cwd": "${workspaceFolder}/out",
      "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
      "windows": {
        "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
      },
      "runtimeArgs": [
        "--enable-logging"
      ],
      "sourceMaps": true,
      "outFiles": [
        "${workspaceFolder}/out/**/*.js"
      ],
      "console": "integratedTerminal",
      "internalConsoleOptions": "openOnSessionStart",
      "preLaunchTask": "prepare-electron-debug"
}

EDIT: Updating version of Node.js to v12 seems to fix the issue.


Does this issue occur when all extensions are disabled?: Yes, same behaviour when launching with disabled extensions

*duplicate debug

Most helpful comment

Workaround is to use the old node-debug with this setting: "debug.javascript.usePreview": false

All 12 comments

Have same issue, but with a different environment and launch options

VSCode Version: 1.47.0
OS Version: MacOS 10.15.5

Launch.json

{
            "type": "node",
            "request": "launch",
            "name": "Core",
            "runtimeExecutable": "nodemon",
            "program": "${workspaceFolder}/app.js",
            "args": [ "--trace-deprecation", "-a", "api"],
            "restart": true,
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen",
            "skipFiles": [
                "<node_internals>/**",
                "${workspaceFolder}/node_modules/**/*.js"
            ]
        }

and this is the error message

env 'NODE_OPTIONS=--require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" ' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/var/folders/r6/b2q51jdj6wdddy37g3r0fl3w0000gn/T/node-cdp.1003-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/Users/tiziano_faion/.nvm/versions/node/v10.13.0/bin/node","onlyEntrypoint":false,"fileCallback":"/var/folders/r6/b2q51jdj6wdddy37g3r0fl3w0000gn/T/node-debug-callback-64674be55b319d21"}' /Users/tiziano_faion/.nvm/versions/node/v10.13.0/bin/nodemon ./app.js --trace-deprecation -a api 
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module '"/Applications/Visual'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:811:12)
    at preloadModules (internal/bootstrap/node.js:594:7)
    at startup (internal/bootstrap/node.js:275:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

i've also tried to solve the issue changing the app name from Visual Studio Code.app to Code.app and relaunching my debug session but i get also an error

Error: Cannot find module '"/Applications/Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js"' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15) at Function.Module._load (internal/modules/cjs/loader.js:506:25) at Module.require (internal/modules/cjs/loader.js:636:17) at Module._preloadModules (internal/modules/cjs/loader.js:811:12) at preloadModules (internal/bootstrap/node.js:594:7) at startup (internal/bootstrap/node.js:275:9) at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

Downgraded to version 1.46.1 and everything worked correctly

Looks like #101996

Thank you! Updating nodejs from v10 to v12 fixed the issue.

Thank you! Updating nodejs from v10 to v12 fixed the issue.

not work(v12.14.1)

This exact issue also happens on windows. Running node 14 so it's not the node version.

Workaround is to use the old node-debug with this setting: "debug.javascript.usePreview": false

Thanks for the issue! Please see https://github.com/microsoft/vscode/issues/102035#issuecomment-656384728

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

@lini can you please also confirm which version of electron you were using?

The project is using electron 8.2.0

Okay, thanks. Just saw your edit that updating to Node 12 fixed it.

A fix for this issue has now been released in VS Code 1.47.2. If you previously had to opt-out of the new debugger, you should be safe to turn it back on. Thanks again for the report!

Was this page helpful?
0 / 5 - 0 ratings