user3183717
user3183717

Reputation: 4667

Angular-CLI ng new: "Error: EPERM: operation not permitted..."

I am trying to use Angular-CLI to install a new Angular2 app, but keep running into the following issue:

ng new payment-calc-app

After "Installing packages for tooling via npm", I get the following Error codes:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\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 ERR! path C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -> 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs'
npm ERR!     at destStatted (C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:29:7)
npm ERR!     at C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -> 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -> 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs'
npm ERR!     at destStatted (C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:29:7)
npm ERR!     at C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -> 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs'
npm ERR!     at Error (native) parent: 'payment-calc-app' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jweston\AppData\Roaming\npm-cache\_logs\2017-03-23T19_17_36_190Z-debug.log

Package install failed, see above.

I've tried npm clean cache and running Command Prompt as an Administrator (I'm on Windows) to no avail.

Oddly enough, when I go to try to delete the folders that the failed installation created, Windows prevents me from deleting them, saying I need to be an Administrator to delete them, even though I am an administrator. I need to go into each individual folder and delete each individual file one at a time.

Upvotes: 16

Views: 41658

Answers (14)

maury844
maury844

Reputation: 1250

In my case the problem was that I had another command prompt with ng serve running. I stopped the process and the creation completed successfully.

Upvotes: 20

Conrado Lopez
Conrado Lopez

Reputation: 161

Being a OS permissions error, before uninstall or reinstall anything, try closing all VSCode windows (and maybe OS windows too). This works for me.

Upvotes: 0

Rasmus
Rasmus

Reputation: 111

If you are running VS Code. Try stop close ALL instances. Open one instance VS Code with Administrator privileges, and add try again

Upvotes: 0

franfonse
franfonse

Reputation: 307

This solved FINALLY for me:

  1. Remove/uninstall Node.js completely from you computer.

  2. Install Node.js from the official website

DONE!

Upvotes: 1

Daniyal Nasir
Daniyal Nasir

Reputation: 707

Following worked for me

  • Open CMD with "Run as administrator"

  • Running cd C:\Users\<USERNAME>\AppData\Roaming\npm (replace <USERNAME> with your user folder)

  • And finally running npm install -g @angular/cli

I have node version v14.17.5 (node -v)

Upvotes: 2

Abhay Singh
Abhay Singh

Reputation: 21

Its a permission issues. So For window 10

  • Open CMD as administrator (Most important)
  • npm uninstall -g @angular/cli
  • npm cache clean
  • npm install -g @angular/cli@latest

Upvotes: 2

Pankaj Sati
Pankaj Sati

Reputation: 2539

I had the same trouble in getting angular cli to work. I tried almost all the possible solutions listed on stackoverflow and other mediums but got failure.

For me what worked was to run an antivirus security scan on my computer. A malicious program was setting the node_modules inside C://users//AppData/roaming/npm to read only mode. Once that virus got removed, I Installed npm and angular cli again and it finally worked.

Upvotes: 0

user13519972
user13519972

Reputation: 33

I had the same problem and the solution that worked for me is running the IntelliJ as an administrator

Upvotes: 3

Jordan Ryder
Jordan Ryder

Reputation: 2812

I know the OP specified they ran it as an Administrator, but for me that solved the issue. Simply running my build as an administrator worked.

Upvotes: 1

72GM
72GM

Reputation: 3114

if you are getting this type of error when you are trying an ng build --prod

close VS Code and in file explorer go to the dist folder (same level as the src folder)... manually delete this

then try again

Upvotes: 0

Anand Bhushan
Anand Bhushan

Reputation: 783

i figured out that this could be due to various reasons, one could be node versions. but mostly and even in my case as @maury844 pointed out, it was due to ng serve running in another command prompt in parallel. deleting npm and npm-cache folders in appdata/roaming could also be related to this issue. try all these.

Upvotes: 1

Alan Gramont
Alan Gramont

Reputation: 39

I had this same issue. I solved it by rolling back to NodeJS LTS. For me, 11.7 Current was the issue. I combed the inter webs and discovered that Current doesn't get tested with NPM all the time, so in a way, Current is how that team tests NodeJS in the wild. Best of luck to anyone having this issue.

Upvotes: 0

Yogesh Patil
Yogesh Patil

Reputation: 171

  • Use command: npm install -g @angular/cli --no-optional
  • Close current angular project folder (in this case payment-calc-app)
  • Give parent folder read & write permission & archive permission (right click parent folder & give permissions to folder & child
    folders)
    • Open NodeJs command prompt in administrator mode
    • Run command ng new payment-calc-app

Upvotes: 8

HydTechie
HydTechie

Reputation: 807

Dear angular 2 coders for survival - this error was pain in the butt, did not resolve with npm cache clean, or restart or other my known methods... Just uninstall previous node version and INSTALL new current version @ https://nodejs.org/en/download/current/ - this resolved the error on my machine..so good luck!

Upvotes: 0

Related Questions