【问题标题】:NPM fails to install @angular/cli saying "File already exists"NPM 无法安装 @angular/cli 说“文件已存在”
【发布时间】:2021-09-16 13:55:39
【问题描述】:

我想安装@angular/cli但它不起作用,我重新安装了Node但问题仍然存在。

文本输出:

MacBook-Pro-de-MAC:~ macayoub$ npm -v
6.14.4
MacBook-Pro-de-MAC:~ macayoub$ node -v
v12.16.2
MacBook-Pro-de-MAC:~ macayoub$ sudo npm install -g @angular/cli
Password:
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/@angular/cli/bin/ng
npm ERR! dest /Users/macayoub/.npm-global/bin/ng
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/@angular/cli/bin/ng' -> '/Users/macayoub/.npm-global/bin/ng'
npm ERR! File exists: /Users/macayoub/.npm-global/bin/ng
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/macayoub/.npm/_logs/2020-04-21T08_23_36_422Z-debug.log

【问题讨论】:

  • 错误信息直接说明了怎么办:“删除现有文件再试一次,或者用--force运行npm鲁莽覆盖文件。”。您是否尝试过使用这两种解决方案中的任何一种?
  • 这能回答你的问题吗? Angular CLI Error path and code EEXIST

标签: node.js angular npm


【解决方案1】:

您需要从 /usr/local/bin 中删除 ng 文件夹 重新安装

sudo rm -rf /usr/local/bin/ng 
sudo npm i -g @angular/cli 

Angular CLI Error path and code EEXIST查找重复的问题

并回答:

https://stackoverflow.com/a/52621562/165260

还请避免发布重复的问题,首先在社区中搜索它们。 快乐编码!

【讨论】:

    【解决方案2】:

    尝试进行全新安装,不要在 NPM 中使用 sudo。有一些关于这个主题的博客:

    【讨论】:

      【解决方案3】:

      如果在 Windows 上遇到类似问题,则执行以下选项:

      1. 导航到路径 C:\Users\AppData\Roaming,这是安装的默认目录
      2. 删除 npm 和 npm-cache 文件夹
      3. 使用命令“npm install -g @angular/cli”重新尝试,这次应该可以工作了

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-20
        • 2023-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-13
        • 2017-08-22
        • 2017-03-23
        相关资源
        最近更新 更多