【问题标题】:Unable to install angular-cli: EPERM -4048 unlink无法安装 angular-cli:EPERM -4048 unlink
【发布时间】:2019-07-30 10:05:31
【问题描述】:

当我尝试通过 npm 安装 angular cli 时,它会出错。我希望这里有人可以告诉我如何修复它,或者以另一种方式安装它。运行 npm install -g @angular/cli 的输出如下:


npm WARN tarball tarball data for rxjs@6.3.3 (sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for typescript@3.2.4 (sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg==) seems to be corrupted. Trying one more time.
npm ERR! path C:\Users\User\AppData\Roaming\npm\node_modules\.staging\typescript-4ae55f23\lib\fr\diagnosticMessages.generated.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\User\AppData\Roaming\npm\node_modules\.staging\typescript-4ae55f23\lib\fr\diagnosticMessages.generated.json'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'C:\Users\User\AppData\Roaming\npm\node_modules\.staging\typescript-4ae55f23\lib\fr\diagnosticMessages.generated.json']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\User\AppData\Roaming\npm\node_modules\.staging\typescript-4ae55f23\lib\fr\diagnosticMessages.generated.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-4ae55f23\\lib\\fr\\diagnosticMessages.generated.json' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-4ae55f23\\lib\\fr\\diagnosticMessages.generated.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-4ae55f23\\lib\\fr\\diagnosticMessages.generated.json',
npm ERR!   parent: '@angular/cli' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-02-11T19_33_51_436Z-debug.log

我不确定是什么导致了这个问题,或者如何解决它。任何帮助将不胜感激。

节点版本为:10.15.1

NPM 版本为:6.7.0

【问题讨论】:

  • 你是以管理员身份运行的吗?
  • 看起来像是权限问题。如果您在 MacOS 上,您可以尝试通过 brew 安装,而不是使用 sudo --> formulae.brew.sh/formula/angular-cli 另一种解决方法是尝试使用 yarn

标签: angular npm angular-cli


【解决方案1】:

我在 github 上找到了这个关于 angular cli 问题页面的解决方案

npm install -global typescript@3.1.6

(请注意安装的是 3.1.6 版本,您可以安装您选择的更高版本)

重新运行命令:

npm install -global @angular/cli

以上解决了错误:WARN tarball tarball data for typescript@3.1.6 (sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==) 似乎已损坏

【讨论】:

    【解决方案2】:

    不了解 Linux 用户,但在 Windows 上这救了我的命。 在c:/users/your user name/roaming/appdata/npm 找到 npm 文件夹 并在同一位置对 npm-cache 执行相同操作 右键单击它并取消选中只读复选框并单击应用,即使 npm 没有直接说它我发现这是一个权限问题,这对我来说非常有效

    【讨论】:

      猜你喜欢
      • 2018-06-13
      • 2015-08-31
      • 1970-01-01
      • 2022-01-06
      • 2018-11-29
      • 2017-08-22
      • 2017-03-23
      • 2019-10-24
      相关资源
      最近更新 更多