Issue Type: Bug
After updating VS Code to the June 2020 release, my debugger would no longer launch, instead throwing an error from loader.js.
I can't remember the error exactly because I've already had to downgrade VS Code to continue working, however, the error was something along the lines of
Could not find module /path/to/AppData/Local/Programs/Microsoft
If needed I'll reinstall the June 2020 release to recreate this.
For reference, my launch.json
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron: Main",
"protocol": "inspector",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"--remote-debugging-port=9223",
"."
],
"env": {
"DEVELOPMENT": "true"
},
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
},
{
"name": "Electron: Renderer",
"type": "chrome",
"request": "attach",
"port": 9223,
"webRoot": "${workspaceFolder}",
"timeout": 30000
},
],
"compounds": [
{
"name": "Electron: All",
"configurations": [
"Electron: Main",
"Electron: Renderer"
]
}
]
}
VS Code version: Code 1.46.1 (cd9ea6488829f560dc949a8b2fb789f3cdc05f5d, 2020-06-17T21:13:20.174Z)
OS version: Windows_NT x64 10.0.18362
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 x 3192)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.86GB (9.53GB free)|
|Process Argv|.|
|Screen Reader|no|
|VM|0%|
Extensions (7)
Extension|Author (truncated)|Version
---|---|---
rust-analyzer|mat|0.2.232
debugger-for-chrome|msj|4.12.9
rust|rus|0.7.8
vscode-todo-list|thi|1.0.4
vscode-counter|uct|2.0.0
vim|vsc|1.14.5
gitblame|wad|4.1.0
Downgrading the May 2020 fixed this issue for me temporarily.
Here we go, apparently installing an older version doesn't update everywhere?
Here's the error output I'm getting.
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '"c:/Users/alexh/AppData/Local/Programs/Microsoft'
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:690:17)
at Module._preloadModules (internal/modules/cjs/loader.js:899:12)
at preloadModules (internal/bootstrap/node.js:601:7)
at startup (internal/bootstrap/node.js:273:9)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Process exited with code 1
Thanks for the issue! This happens if you're running Node <= 10 and not using node as your runtimeExecutable, preventing us from being able to know for sure what version you're on.
To use the old set of debuggers, you can add the setting debug.javascript.usePreview: false to your user settings. Alternately, you can update to Node 12 or higher.
It's apparent that there needs to be a way to explicitly signal older Node versions for cases like these.
On further thought, I have changed the behavior to always attempt to find node on path whenever the binary isn't already Node. This should solve all relevant cases.
You can grab the latest nightly release of the debugger once it becomes available (in about 1.5 hrs from now).
Thanks for replying to this so quickly. I think I will stick with the May 2020 version for now, and periodically check for when this makes it into a stable version.
Thanks!
Ok, apologies for the trouble! I aim to get this fix into our first recovery release (likely to happen early/mid next week)
On further thought, I have changed the behavior to always attempt to find
nodeon path whenever the binary isn't already Node. This should solve all relevant cases.You can grab the latest nightly release of the debugger once it becomes available (in about 1.5 hrs from now).
I'm still getting the error with the nightly debugger. Have the changes been released yet?
They have. But maybe the binary detected on your PATH is newer, or maybe we can't find node at all.
For these cases I've added an additional launch option that you can use like "nodeVersionHint": 10 in your launch.json to override the default version detection. A new nightly (version 2020.7.1010) with this option will be available in a couple minutes.
Edit: my assumption around how things work was incorrect. See the following comment
Confirmed that the common variant of this problem, running with Electron, is present if the following two things are true:
electron.cmd/electron in the runtimeExecutableThis can be resolved by:
nodeVersionHint: 10 to signal that we'll run with an older Node version.debug.javascript.usePreview: false to use the old debugger until a fix for this is releasedI ~will~ have put in a fix to js-debug that does some special detection for Electron versions so that no changes config changes will be needed in the future.
Verification steps. Grab nvm if you don't already have it.
runtimeExectuable: 10 if you installed Node 10 via nvm). Verify it still works.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!
Most helpful comment
Confirmed that the common variant of this problem, running with Electron, is present if the following two things are true:
electron.cmd/electronin the runtimeExecutableThis can be resolved by:
nodeVersionHint: 10to signal that we'll run with an older Node version.debug.javascript.usePreview: falseto use the old debugger until a fix for this is releasedI ~will~ have put in a fix to js-debug that does some special detection for Electron versions so that no changes config changes will be needed in the future.