无法将npm从6.14.8更新到7.3;删除npm.cmd、npx.cmd和npm会导致更多错误



我一直在尝试使用Git Bash中的npm install -g npm命令全局更新我的npm,以保持Angular 11和Node.js 15.5.0版本的最新版本。我收到以下错误:

npm ERR! code EEXIST
npm ERR! path C:Program Filesnodejsnpm.cmd
npm ERR! Refusing to delete C:Program Filesnodejsnpm.cmd: is outside C:Program Filesnodejsnode_modulesnpm and not a link
npm ERR! File exists: C:Program Filesnodejsnpm.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

我从nodejs中删除了该文件,并尝试再次安装,但收到了另一个关于npx.cmd的错误。我删除了那个文件,尝试安装,并收到一个关于npm文件的错误。

npm ERR! code EEXIST
npm ERR! path C:Program Filesnodejsnpx.cmd
npm ERR! Refusing to delete C:Program Filesnodejsnpx.cmd: is outside C:Program Filesnodejsnode_modulesnpm and not a link
npm ERR! File exists: C:Program Filesnodejsnpx.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! code EEXIST
npm ERR! path C:Program Filesnodejsnpm
npm ERR! Refusing to delete C:Program Filesnodejsnpm: is outside C:Program Filesnodejsnode_modulesnpm and not a link
npm ERR! File exists: C:Program Filesnodejsnpm
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

在删除它们并尝试再次安装npm之后,Git Bash不再找到npm。安装从未开始。

bash: /c/Program Files/nodejs/npm: No such file or directory

我试图从AppData中的漫游文件夹中删除npm文件,但收到以下错误:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:UsersYoga 2 MitchellAppDataRoamingnpm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:UsersYoga 2 MitchellAppDataRoamingnpm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

我也在不同的时间尝试过以下内容:

  • 删除node_modules并重新安装npm
  • 使用npm 7.3.0的Git存储库创建一个新的npm文件(?((我需要再次在网上找到建议,以澄清/提供更多细节(
  • 清理缓存
  • 卸载并重新安装Angular 11 CLI和Node.js(已尝试用于LTS和当前版本(

到目前为止一切都不起作用。我在上面列表中尝试的第二种方法能够将其更新到6.14.10,但这次尝试返回的错误似乎影响了Angular。为了安全起见,我把所有东西都恢复到原来的状态。请让我知道,如果我可以澄清任何其他关于我的问题。

我与另一位开发人员联系了我收到的错误。提出了以下方法,它可以解决LTS的问题:如何从Windows 中完全删除node.js

LTS版本允许我更新到npm的6.14.11,但当我尝试这种方法安装当前版本时,它仍然是6.14.11。希望这种方法能帮助其他遇到类似错误的人。

最新更新