Vscode-js-debug: Error: Cannot find module '"/Applications/Visual' when launching `pwa-node` with `npm`

Created on 26 Jun 2020  路  18Comments  路  Source: microsoft/vscode-js-debug

Version: 1.46.1
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:17:14.222Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0

When I try to debug a project such as this absolute minimal example I cannot launch the Launch via NPM configuration.

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)

irrespective of using debug.javascript.usePreview on or off. (see example repo)

I have cleared my cache in $HOME/Library/Application Support/Code and disabled ALL extensions, all to no avail.

bug verified

Most helpful comment

I had the same problem and restarting VSCode fixed it... 馃

All 18 comments

Same launching it in WSL:

Version: 1.46.1 (user setup)
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/home/kristof/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/extensions/ms-vscode.js-debug/src/bootloader.bundle.js"'
    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)

What node --version do you have?

This looks like we're detecting Node >=11 from the extension (which fixed their argument parsing to allow us to use spaces and wrap paths in quotes) but you're actually running Node 10.

Oh, nevermind. We skip validation if the runtime executable isn't node.

https://github.com/microsoft/vscode-js-debug/blob/8154352894f15140f181385d1a3e8af084241be3/src/targets/node/nodeBinaryProvider.ts#L48-L52

I think for the purposes of version querying we could rewrite npm to node to fix this.

Fixed in the next nightly. For yarn, npm, and pnpm, we will attempt to resolve the underlying node version.

Thanks @connor4312 !

Verification steps:

  1. Use Node 10. nvm or a dev container would work well
  2. Have a launch config as linked where the runtimeExecutable is set to npm, yarn, or pnpm
  3. Verify that you can successfully run and debug scripts

Have a launch config as linked where the runtimeExecutable is set to npm, yarn, or pnpm

"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
  "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},

Electron has same issue.

Still:

Verbose logs are written to:
C:\Users\1\AppData\Local\Temp\vscode-debugadapter-17.json.gz
X:\Repos\Cocos\editor-3d/node_modules/.bin/electron.cmd ./app --pass-through --dev
Debugger listening on ws://127.0.0.1:14371/c71844bd-a66d-46d5-b9cf-f908bee4d84a
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

internal/modules/cjs/loader.js:686
    throw err;
    ^

Error: Cannot find module '"c:/Users/1/AppData/Local/Programs/Microsoft'
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:683:15)
    at Function.Module._load (internal/modules/cjs/loader.js:601:27)
    at Module.require (internal/modules/cjs/loader.js:739:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:971:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:365:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:48:3)
    at internal/main/run_main_module.js:14:1

I have installed the nightly debugger(from store) and enable:

"debug.javascript.usePreview": true,

Can you share the trace log?

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!

@connor4312 I am still receiving this issue using vscode 1.51.0 on macOS Catalina

Debugger listening on ws://127.0.0.1:61001/0054e6da-ca4e-41f4-a36a-78bfe8410a10
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
internal/modules/cjs/loader.js:1033
  throw err;
  ^

Error: Cannot find module '/Users/mikee/scripts/examples/test-arrays.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15)
    at Function.Module._load (internal/modules/cjs/loader.js:899:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

That is not a debugger-related error.

I had the same problem and restarting VSCode fixed it... 馃

@harrisgeo88 That worked for me! Thanks!

@connor4312
Hello, I have the same problem.
I tried to restart did not improve the situation.
Can't you see what's not right?

output log

/Users/niioka-kenshiro/.anyenv/envs/nodenv/shims/node ./myProjectDir/index.js
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)
Process exited with code 1

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/myProjectDir/index.js"
        }
    ]
}

About my VSCode

Version: 1.52.1
Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523
Date: 2020-12-16T16:30:02.420Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

myProject Node version

niioka-kenshiro:myProjectDir niioka-kenshiro$ node --version
v10.14.1

I have the same issue after updating my node version today.

    {
        "name": "Launch via NPM",
        "type": "node",
        "request": "launch",
        "cwd": "${workspaceRoot}",
        "runtimeExecutable": "npm",
        "runtimeArgs": [
            "run-script", "foo", "--max-old-space-size=8192", "--expose-gc", "--trace_gc"
        ],
        //"port": 5858,
        "skipFiles": [
            "<node_internals>/**"
        ],
        "program": "${workspaceFolder}/foo.js",

    }

Thanks for the comment, can you open a new issue and include the log using the instructions in the template?

Was this page helpful?
0 / 5 - 0 ratings