【发布时间】: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