Recently, I've become unable to run the JavaScript Debug Terminal in VS Code for my Node.js projects. I have a number of different projects all built on the same base, and trying to run npm start
in a debug terminal for any of them gives me the following error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '"c:/Users/malcolm.mccrimmon/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:692:17)
at Module._preloadModules (internal/modules/cjs/loader.js:901: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)
Waiting for the debugger to disconnect...
Running npm start
from any other, non-debug terminal works just fine. Searching for this problem has only turned up a few issues with debugging projects that have been recently moved, or for which dependencies have not been installed correctly (e.g. vscode Debugger Cannot find module and internal/modules/cjs/loader.js:582 throw err).
I'm using a local (User) installation of VS Code and C:\Users\malcolm.mccrimmon\AppData\Local\Programs\Microsoft VS Code
is the installation directory, so it looks like it may be an issue with a space in the file path not being escaped correctly? I have no idea how to fix it.
I thought maybe it was a bug introduced in a recent update to VS Code, but I tried downgrading all the way to the January 2021 build (v 1.53) and was still able to reproduce it. A full uninstall and reinstall also failed to resolve the issue. At this point I'm not sure what else to try.
Below is one of the simpler package.json files among the projects I've reproduced this issue in:
{
"name": "metrics-graphql",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon -L index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"node": "10.16"
},
"dependencies": {
"apollo-boost": "^0.4.9",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-http": "^1.5.17",
"apollo-server": "^2.25.3",
"apollo-server-express": "^2.25.3",
"axios": "^0.19.2",
"dataloader": "^2.0.0",
"dotenv": "^8.6.0",
"elasticsearch": "^16.7.2",
"graphql": "^14.7.0",
"graphql-iso-date": "^3.6.1",
"graphql-redis-subscriptions": "^2.4.2",
"graphql-resolvers": "^0.4.2",
"graphql-subscriptions": "^1.2.1",
"https-proxy-agent": "^5.0.0",
"ioredis": "^4.28.2",
"moment": "^2.29.1",
"mongoose": "^5.13.13",
"node-fetch": "^2.6.6"
}
}