David
David

Reputation: 585

Trouble installing @angular/cli

I am having substantial problems installing @angular/cli.

$ node -v
v8.11.3

When I run the command:

$ npm install @angular/cli

I get the following messages in the log file:

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

Full:

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 [email protected]
3 info using [email protected]
4 verbose npm-session d71a3e8af10f9305
5 silly install loadCurrentTree
......
4670 silly saveTree   `-- [email protected]
4670 silly saveTree     `-- [email protected]
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: [email protected] (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: [email protected] (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: [email protected] (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 ]

I was actually running cmd.exe as the administrator so I the complaint about not installing as admin seems misdirected. Has anyone else had this issue or can suggest a reason/solution?

I'm on Windows 7 Professional.

I'm attempting to install angular globally.

I have run npm cache verify and it says:

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

I then re-ran the install command thus (this time with the -g flag):

C:\Users\my-user-name\Documents\angular-app>npm install -g @angular/cli
npm WARN rollback Rolling back [email protected] 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.

I then tried the following commands with this result:

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: [email protected] (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (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.

I then exited the terminal, re-ran the "npm cache clean" and "npm cache verify" and then started a new Administrator terminal, and tried the install again.

C:\Users\my-user-name\Documents\angular-app>npm install -g @angular/cli
npm WARN rollback Rolling back @angular/[email protected] 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: [email protected] (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (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.

Any thoughts/suggestions are greatly appreciated.

thanks heaps,

David.

POSTSCRIPT: It turned out that I didn't have full admin rights to the laptop I was working on [I usually work on a different PC for which I have full admin rights]. I got my corporate tech support guys to grant me full admin rights to this particular laptop, and after that the install worked just fine. Thanks heaps for everyone who has offered assistance, and particularly to Ulrich who identified the admin rights issue.

Upvotes: 1

Views: 3457

Answers (2)

mahval
mahval

Reputation: 2213

In this specific order:

  1. Remove your node_modules folder $ rm -rf node_modules
  2. $ npm cache verify
  3. $ npm install -g @angular/cli
  4. $ npm install

If this does not help the only other thing I can think of is running:

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

Upvotes: 1

Ulrich Dohou
Ulrich Dohou

Reputation: 1559

To install the Angular CLI here are the steps.

Globaly

npm install -g @angular/cli 

or

yarn global add @angular/cli

Localy

npm install -D @angular/cli 

or

yarn add -D @angular/cli

Clear Cache first to avoid any issue

npm cache clean --force

or

yarn cache clean

Upvotes: 1

Related Questions