安装了Node.js ,npm等命令在vscode无效

本文介绍了解决在VScode中遇到的npm命令无效的问题。通常这种情况发生在刚刚安装完Node.js之后,因为VScode终端可能不会立即更新环境变量。解决办法是关闭VScode并重新启动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如果是下载的zip压缩包解压后要自己配置到系统环境变量中。

明明已经下载node.js了,但是在vscode中npm命令无效了。

因为在安装Node.js软件包的时候就打开VScode,所以你觉得可能是因为VScode的终端不会实时去检测新增的环境变量而是只在打开VScode初始化的时候只检测一次导致的,所以关掉VScode重新打开一个VScode就可以在终端下使用node -v 和  npm -v 等软件包里面包含的命令了。

微信公众号:CS阿吉

 

我按照上面说的在终端执行npm install express multer mysql cors --save时出现了如下报错:npm error code EPERM npm error syscall mkdir npm error path D:\myApps\Node.js\node_cache\_cacache npm error errno -4048 npm error Error: EPERM: operation not permitted, mkdir 'D:\myApps\Node.js\node_cache\_cacache' npm error at async mkdir (node:internal/fs/promises:857:10) npm error at async Object.insert (D:\myApps\Node.js\node_modules\npm\node_modules\cacache\lib\entry-index.js:124:5) npm error at async CacheEntry.store (D:\myApps\Node.js\node_modules\npm\node_modules\make-fetch-happen\lib\cache\entry.js:308:7) npm error at async fetch (D:\myApps\Node.js\node_modules\npm\node_modules\make-fetch-happen\lib\fetch.js:98:7) npm error at async RegistryFetcher.packument (D:\myApps\Node.js\node_modules\npm\node_modules\pacote\lib\registry.js:90:19) npm error at async RegistryFetcher.manifest (D:\myApps\Node.js\node_modules\npm\node_modules\pacote\lib\registry.js:128:23) npm error at async #fetchManifest (D:\myApps\Node.js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1202:20) npm error at async #nodeFromEdge (D:\myApps\Node.js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1040:19) npm error at async #buildDepStep (D:\myApps\Node.js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:904:11) npm error at async Arborist.buildIdealTree (D:\myApps\Node.js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:181:7) { npm error errno: -4048, npm error code: 'EPERM', npm error syscall: 'mkdir', npm error path: 'D:\\myApps\\Node.js\\node_cache\\_cacache', npm error requiredBy: '.' npm error } npm error npm error The operation was rejected by your operating system. npm error It's possible that the file was already in use (by a text editor or antivirus), npm error or that you lack permissions to access it. npm error npm error If you believe this might be a permissions issue, please double-check the npm error permissions of the file and its containing directories, or try running npm error the command again as root/Administrator. npm error Log files were not written due to an error writing to the directory: D:\myApps\Node.js\node_cache\_logs npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal 这是什么原因,如何解决
03-19
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值