【问题标题】:I get an error when intalling Angular CLI with npm使用 npm 安装 Angular CLI 时出现错误
【发布时间】:2018-03-16 01:25:30
【问题描述】:

我尝试重新安装 node.js 几次,并尝试使用不同的版本,但我仍然得到相同的错误。我还以管理员身份运行 CMD。好像没有找到json-schema,我什至尝试手动安装它,但出现同样的错误。这是我收到的错误消息:

C:\> npm install -g @angular/cli
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\admin\AppData\Roaming\npm\node_modules\.staging\fsevents-edb66af1\node_modules\asn1' -> 'C:\Users\admin\AppData\Roaming\npm\node_modules\.staging\asn1-98b68b78'

npm ERR! path C:\Users\admin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@ngtools\json-schema
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\admin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@ngtools\json-schema' -> 'C:\Users\admin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@ngtools\.json-schema.DELETE'
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\admin\AppData\Roaming\npm-cache\_logs\2018-03-15T07_42_19_026Z-debug.log

【问题讨论】:

  • 试试npm cache clean --force
  • 可能会检查并更新你的 npm

标签: node.js angular npm


【解决方案1】:

最好的方法就是像你一样,首先,尝试从你的机器上卸载 node 和 angular 并删除相关文件,然后再一个一个地安装它,它会像我之前遇到过同样的问题一样工作。我附上了一些帮助我删除角度和节点的链接。

How to completely remove node.js from Windows

用于完全去除角

npm 卸载 -g @angular/cli

npm 缓存验证

【讨论】:

  • 它也不起作用。我删除了所有内容,但它引发了同样的错误。
【解决方案2】:

你运行的是什么版本的 npm ('npm -v')?

我建议您至少运行 npm 版本 5.3.0 - 当前版本是 5.7.1,但我遇到了一些更高版本的 Windows 上的权限行为问题(与其他人一样)。

如果您需要安装不同版本的 npm,请输入命令 npm install -g npm@5.3.0(或您要安装的任何版本)。

【讨论】:

    猜你喜欢
    • 2023-03-29
    • 2019-03-29
    • 2018-11-10
    • 1970-01-01
    • 2017-06-21
    • 2020-12-19
    • 1970-01-01
    • 2019-07-08
    • 2018-06-03
    相关资源
    最近更新 更多