为什么 VsCode NPM 会抛出未找到模块的错误? [英] Why does VsCode NPM throw a module not found error?

查看:60
本文介绍了为什么 VsCode NPM 会抛出未找到模块的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我完全没有问题,但是有一天,每当我尝试使用 nodejs 命令时,VsCode 都开始抛出错误.例如,即使 NPM -V 也会引发错误.我试图删除环境变量并重新应用它们以及重新启动,我什至在程序文件和 appData 下从我的系统中完全擦除了 nodejs 并重新安装了它.如果我转到正常的 cmd Windows 提示,我会遇到零问题.但是,如果我在 vscode 中,我会收到以下错误:

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) 

这只是 VScode 中的一个简单版本命令.在此先感谢您的帮助!

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

推荐答案

我能够通过在 VsCode 中按 F1 并选择 cmd 作为默认终端选项来解决此问题.vscode 的人实际上帮助了我!https://github.com/Microsoft/vscode/issues/65893

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 :)

这篇关于为什么 VsCode NPM 会抛出未找到模块的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆