0

Typically I have no issues at all but however the other day VsCode started throwing a error anytime I tried to use a nodejs command. For instance even NPM -V throws a error. I have attempted to delete the environmental variables and reapply them as well as restart and I even completely wiped nodejs from my system both under program files and appData and re installed it. If I goto a normal cmd windows prompt I get zero issues. However if I am inside of vscode I get the below error:

 npm -v
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'E:\c\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'E:\c\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) 

This is just a simple version command in VScode. Thanks in advance for the help!

Robert
  • 343
  • 6
  • 16

2 Answers2

3

I was able to resolve this by pressing F1 in VsCode and selecting the cmd as the default terminal option. The guys at vscode actually helped me! https://github.com/Microsoft/vscode/issues/65893

Thanks! Hopefully this helps someone in the future :)

Robert
  • 343
  • 6
  • 16
0

If selecting the simple CMD as the default terminal in VsCode does not fix this problem for some, try running VsCode as an administrator.

SeaMouse
  • 21
  • 1
  • 6
  • @Yunnosch - I've taken the effort to try to address your feedback, so would appreciate acknowledgement of some kind. – SeaMouse Jan 12 '22 at 07:09
  • Yes, now it looks like an attempt to answer the question. (Maybe even is a solution, but that I cannot tell for lack of knowledge.). Thanks for reacting to my feedback. – Yunnosch Jan 12 '22 at 11:15