如何解决 install -g yarn 上的 npm 错误?

问题描述

我想运行这个命令并安装yarn

npm install -g yarn

但我收到此错误

npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\DigiMax\AppData\Roaming\npm\node_modules\yarn
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\DigiMax\AppData\Local\npm-cache\_logs\2021-07-03T15_03_24_683Z-debug.log

我该如何解决这个问题?

解决方法

最快的解决方案是 npm cache clean,而 npm cache verify 在大多数情况下都有效。

根据docs.npmjs,您应该检查您的 npm 版本并在需要时更新或在最坏的情况下重新安装它。

请告诉我们它是否有效

,

此问题通过“以管理员身份运行VSCode”解决