无法安装angular-cli:EPERM -4048取消链接

时间:2019-02-11 19:54:21

标签: angular npm angular-cli

当我尝试通过npm安装角度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

2 个答案:

答案 0 :(得分:1)

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

npm install -global typescript@3.1.6

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

重新运行命令:

npm install -global @angular/cli

以上内容解决了错误:警告typescript@3.1.6的tarball tarball数据(sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF / t2 + uKoX0BBa0hXXwDlqY = by5BA

答案 1 :(得分:0)

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