无法安装@ angular / cli

时间:2018-06-14 07:54:15

标签: angular

我在安装@angular/cli时遇到很多问题。

$ node -v
v8.11.3

当我运行命令时:

$ npm install @angular/cli

我在日志文件中收到以下消息:

4697 error Please try running this command again as root/Administrator.

全:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '@angular/cli' ]
2 info using npm@5.6.0
3 info using node@v8.11.3
4 verbose npm-session d71a3e8af10f9305
5 silly install loadCurrentTree
......
4670 silly saveTree   `-- yargs-parser@10.0.0
4670 silly saveTree     `-- camelcase@4.1.0
4671 warn enoent ENOENT: no such file or directory, open 'C:\Users\my-user-name\Documents\angular\package.json'
4672 verbose enoent This is related to npm not being able to find a file.
4673 warn angular No description
4674 warn angular No repository field.
4675 warn angular No README data
4676 warn angular No license field.
4677 warn optional SKIPPING OPTIONAL DEPENDENCY: console-control-strings@1.1.0 (node_modules\fsevents\node_modules\console-control-strings):
4678 warn optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\fsevents\node_modules\console-control-strings\package.json.3920028646' -> 'C:\Users\my-user-name\Documents\angular\node_modules\fsevents\node_modules\console-control-strings\package.json'
4679 verbose optional SKIPPING OPTIONAL DEPENDENCY:
4679 verbose optional Please try running this command again as root/Administrator.
4680 warn optional SKIPPING OPTIONAL DEPENDENCY: brace-expansion@1.1.11 (node_modules\fsevents\node_modules\brace-expansion):
4681 warn optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\fsevents\node_modules\brace-expansion\package.json.2801661485' -> 'C:\Users\my-user-name\Documents\angular\node_modules\fsevents\node_modules\brace-expansion\package.json'
4682 verbose optional SKIPPING OPTIONAL DEPENDENCY:
4682 verbose optional Please try running this command again as root/Administrator.
4683 warn optional SKIPPING OPTIONAL DEPENDENCY: concat-map@0.0.1 (node_modules\fsevents\node_modules\concat-map):
4684 warn optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\fsevents\node_modules\concat-map\package.json.715155234' -> 'C:\Users\my-user-name\Documents\angular\node_modules\fsevents\node_modules\concat-map\package.json'
4685 verbose optional SKIPPING OPTIONAL DEPENDENCY:
4685 verbose optional Please try running this command again as root/Administrator.
4686 verbose stack Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json.1187479171' -> 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json'
4687 verbose cwd C:\Users\my-user-name\Documents\angular
4688 verbose Windows_NT 6.1.7601
4689 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@angular/cli"
4690 verbose node v8.11.3
4691 verbose npm  v5.6.0
4692 error path C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json.1187479171
4693 error code EPERM
4694 error errno -4048
4695 error syscall rename
4696 error Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json.1187479171' -> 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json'
4696 error  { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json.1187479171' -> 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json'
4696 error   cause:
4696 error    { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json.1187479171' -> 'C:\Users\my-user-name\Documents\angular\node_modules\union-value\package.json'
4696 error      errno: -4048,
4696 error      code: 'EPERM',
4696 error      syscall: 'rename',
4696 error      path: 'C:\\Users\\my-user-name\\Documents\\angular\\node_modules\\union-value\\package.json.1187479171',
4696 error      dest: 'C:\\Users\\my-user-name\\Documents\\angular\\node_modules\\union-value\\package.json' },
4696 error   stack: 'Error: EPERM: operation not permitted, rename \'C:\\Users\\my-user-name\\Documents\\angular\\node_modules\\union-value\\package.json.1187479171\' -> \'C:\\Users\\my-user-name\\Documents\\angular\\node_modules\\union-value\\package.json\'',
4696 error   errno: -4048,
4696 error   code: 'EPERM',
4696 error   syscall: 'rename',
4696 error   path: 'C:\\Users\\my-user-name\\Documents\\angular\\node_modules\\union-value\\package.json.1187479171',
4696 error   dest: 'C:\\Users\\my-user-    name\\Documents\\angular\\node_modules\\union-value\\package.json' }
4697 error Please try running this command again as root/Administrator.
4698 verbose exit [ -4048, true ]

我实际上是以管理员身份运行cmd.exe所以我抱怨没有安装为管理员似乎是错误的。有没有其他人有此问题或可以提出理由/解决方案?

我使用的是Windows 7 Professional。

我正在尝试全局安装角度。

我已经运行了npm cache verify,它说:

C:\Users\my-user-name\Documents\angular-app>npm cache verify
Cache verified and compressed (~\AppData\Roaming\npm-cache\_cacache):
Content verified: 427 (14435322 bytes)
Index entries: 648
Finished in 11.729s

然后我重新运行了install命令(这次使用-g标志):

C:\Users\my-user-name\Documents\angular-app>npm install -g @angular/cli
npm WARN rollback Rolling back is-number@4.0.0 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-odd\node_modules'
npm ERR! path C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json.222949292
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json.222949292' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json'
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json.222949292' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json.222949292' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\anymatch\package.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\anymatch\\package.json.222949292',
npm ERR!      dest: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\anymatch\\package.json' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\anymatch\\package.json.222949292\' -> \'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\anymatch\\package.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\anymatch\\package.json.222949292',
npm ERR!   dest: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\anymatch\\package.json',
npm ERR!   parent: '@angular/cli' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

然后我尝试了以下命令:

C:\Users\my-user-name\Documents\angular-app>npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.

C:\Users\my-user-name\Documents\angular-app>npm install -g @angular/cli
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: has-unicode@2.0.1 (node_modules\@angular\cli\node_modules\has-unicode):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\has-unicode\package.json.2373703784'

npm ERR! path C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json.3260818882
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json.3260818882' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json'
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json.3260818882' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json.3260818882' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\isstream\package.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\isstream\\package.json.3260818882',
npm ERR!      dest: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\isstream\\package.json' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\isstream\\package.json.3260818882\' -> \'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\isstream\\package.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\isstream\\package.json.3260818882',
npm ERR!   dest: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\isstream\\package.json',
npm ERR!   parent: '@angular/cli' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

然后我退出终端,重新运行“npm cache clean”和“npm cache verify”,然后启动一个新的Administrator终端,并再次尝试安装。

C:\Users\my-user-name\Documents\angular-app>npm install -g @angular/cli
npm WARN rollback Rolling back @angular/cli@6.0.8 failed (this is probably harmless): EPERM: operation not permitted, rmdir 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: jsbn@0.1.1 (node_modules\@angular\cli\node_modules\jsbn):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\jsbn\package.json.2015622704' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\jsbn\package.json'

npm ERR! path C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json.903151167
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json.903151167' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json'
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json.903151167' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, rename 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json.903151167' -> 'C:\Users\my-user-name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\is-windows\package.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\is-windows\\package.json.903151167',
npm ERR!      dest: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\is-windows\\package.json' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\is-windows\\package.json.903151167\' -> \'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\is-windows\\package.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\is-windows\\package.json.903151167',
npm ERR!   dest: 'C:\\Users\\my-user-name\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\is-windows\\package.json',
npm ERR!   parent: '@angular/cli' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

非常感谢任何想法/建议。

谢谢堆,

大卫。

POSTSCRIPT:事实证明我对我正在处理的笔记本电脑没有完全的管理员权限[我通常在不同的PC上工作,我有完全的管理权限]。我得到了我的公司技术支持人员给我这个特定笔记本电脑的完全管理员权限,之后安装工作得很好。感谢所有提供帮助的人,特别是对于确定管理员权利问题的Ulrich。

2 个答案:

答案 0 :(得分:1)

按此特定顺序:

  1. 删除node_modules文件夹$ rm -rf node_modules
  2. $ npm cache verify
  3. $ npm install -g @angular/cli
  4. $ npm install
  5. 如果这对我唯一能想到的其他事情无效:

    $ npm install -g @angular/cli --no-optional

答案 1 :(得分:1)

要安装Angular CLI,请执行以下步骤。

Globaly

npm install -g @angular/cli 

yarn global add @angular/cli

Localy

npm install -D @angular/cli 

yarn add -D @angular/cli

首先清除缓存以避免任何问题

npm cache clean --force

yarn cache clean