Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Integrated Terminal Throws `Cannot find module` & `nvm is not compatible with the npm config "prefix" option`

It looks like this is a fairly common issue, but I've tried everything I can find and still can't seem to resolve it. If I load my terminal outside of VS Code it works fine, but the integrated terminal keeps throwing this when it starts:

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

Error: Cannot find module '"/Users/me/Library/Application'
    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)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v10.16.3 --silent` to unset it.

I worked through the steps here, which explain how to remove additional unwanted instances of npm/npx. The strange thing is that now which npm prints /Users/me/.nvm/versions/node/v10.16.3/bin/npm before the nvm initialization script, which makes it seem like nvm has been loaded properly, but the .zshrc file is being run again, which might be causing the errors.

It looks like there's an extra " in the file path in the error message ('"/Users/me/Library/Application'), but I don't see any typos like that in my nvm initialization script, so it seems like maybe it's also a result of the initialization script being called twice?

Something else of note is that node and npm can't be found in the integrated terminal, but they work fine outside of VS Code.

I've also tried various other things like setting this in my VS Code settings: "terminal.integrated.shellArgs.osx": [], uninstalling and reinstalling node/nvm both manually and with homebrew. Any help would be greatly appreciated!

Edit: I tried installing VS Code Insiders and copying over my settings and the integrated terminal loads without any issues. So it seems like this might be fixed in a future release. I'll post an update after the update is available in VS Code to see if this issue goes away.

like image 661
jeffbernst Avatar asked Jul 15 '20 19:07

jeffbernst


People also ask

Why terminal is not opening in VS code?

Changing Default Command Line Shell Then, click on the arrow on the side of a plus (+). Here, choose Select Default Profile. Then, select any other type of command line shell. Then, restart vs code and try working on terminal.


1 Answers

I had this problem and I was just able to fix my issues by disabling auto attaching for debug in the VSCode settings. Hopefully I can re-enable this in the future since you mentioned there aren't issues with the latest insider release. I'm using a Bash shell by the way but hopefully this will help you as well.

"debug.node.autoAttach": "disabled",
like image 186
bergy Avatar answered Oct 08 '22 20:10

bergy