Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm install fails on Windows: "Error: EPERM: operation not permitted, rename" #10826

Closed
barbalex opened this issue Dec 15, 2015 · 139 comments
Closed

Comments

@barbalex
Copy link

I work on Windows 10, up to date installation.
npm i runs in powershell
node v5.2.0
npm v3.3.12

This error occures every time. I have repeated 5 times, deleting the node_modules folder beforehand.
I have also run it twice as administrator.
It works on my OsX notebook.

Here the error message in powershell:

npm WARN EPACKAGEJSON [email protected] No repository field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
npm ERR! node v5.2.0
npm ERR! npm  v3.3.12
npm ERR! path C:\Users\alex\ae\node_modules\.staging\escope-b5ac5ca528edb372dbff854e4a2941fb
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\alex\ae\node_modules\.staging\escope-b5ac5ca528edb372db
ff854e4a2941fb' -> 'C:\Users\alex\ae\node_modules\escope'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, rename 'C:\Users\alex\ae\node_modules\.staging\escope-b5ac5ca528edb3
72dbff854e4a2941fb' -> 'C:\Users\alex\ae\node_modules\escope']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\alex\\ae\\node_modules\\.staging\\escope-b5ac5ca528edb372dbff854e4a2941fb',
npm ERR!   dest: 'C:\\Users\\alex\\ae\\node_modules\\escope',
npm ERR!   parent: 'ae' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\alex\ae\npm-debug.log

This is the complete log from npm-debug.log: https://gist.github.com/barbalex/da6100299bf5b76f19c2

This is the project: https://github.com/barbalex/ae
This is package.json: https://github.com/barbalex/ae/blob/master/package.json

@richardscarrott
Copy link

I was getting the same issue, npm cache clean fixed it for me :)

@barbalex
Copy link
Author

@richardscarrott : thanks, will try that next time. Unfortunately this type of issues keep happening to me quite often so your tipp could turn out to be very helpful.

Don't ask me why but the next morning this issue had disappeared and npm i works nicely. So I close the issue but I'm quite sure it will return for me.

@defmans7
Copy link

I disabled Avast which allowed me to get around this issue.
https://www.webfoobar.com/node/39

@hsingh23
Copy link

Why was this issue closed? What was the root cause of this problem? Do we have to clear cache for every install?

@mohanr
Copy link

mohanr commented Mar 20, 2016

npm ERR! Error: EPERM: operation not permitted, open 'D:\WebstormProjects\Frisby
\node_modules\karma\node_modules\isbinaryfile\test\fixtures\pdf.pdf'

It happens. I run as admin.

@kneerunjun
Copy link

Yeah! npm cache clean worked for me too! cheers 🍷

@ganeshran
Copy link

npm cache clean fixed the issue for me too

@franklin-vidal
Copy link

Check if another application is using the project folder, like Atom editor. In my case i close Atom, run node and open editor again.

@john-osullivan
Copy link

I've gotten this issue in the past (and just got it again, prompting me to Google and remember) when the project folder I'm operating on is within Dropbox. Particularly after running generate commands which suddenly produce a lot of files, it seems like Dropbox's syncing code locks up files and prevents NPM from renaming as necessary.

@linfangwu
Copy link

Open cmd prompt by right clicking and then click "open as administrator"

@priiduneemre
Copy link

priiduneemre commented Apr 21, 2016

Also, be sure to disable your anti-malware and antivirus software temporarily. This solved the problem for me (Windows Antimalware Service & Avast Free Antivirus in my case).

@chrahunt
Copy link

chrahunt commented Jun 1, 2016

I had this same issue and none of the above solutions worked. The specific operation that failed was

npm ERR! Error: EPERM: operation not permitted, rename 'c:\[...]\node_modules\node-sass' -> 'c:\[...]\node_modules\.node-sass.DELETE'

It seems like the problem was that .node-sass.DELETE already existed, as moving it allowed the installation to proceed.

@UnderZerOx
Copy link

UnderZerOx commented Jun 9, 2016

@richardscarrott | TY, worked for me.

@Sandiejat
Copy link

yes, seems like either anti-virus is locking the installation folder for that particular file or the user is not with elevated rights. Disabling McAfee worked for me.

@mohanr
Copy link

mohanr commented Jun 25, 2016

I did something similar. Fixed many such problems. But in my case the
scanner rules were updated after the security team looked at the logs.I
didn't disable the scanner. That is an extreme measure.

Mohan

On 25 June 2016 at 06:55, Sandeep Verma [email protected] wrote:

yes, seems like either anti-virus is locking the installation folder for
that particular file or the user is not with elevated rights. Disabling
McAfee worked for me.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#10826 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAWamtcFRjCekuJJXFV1t2AhufAB3fzOks5qPIOCgaJpZM4G1m67
.

@johnwonder
Copy link

npm cache clean fixed the issue for me too

@southnan0
Copy link

what is means in npm of -4048

@happy2share
Copy link

happy2share commented Jul 30, 2016

I don't know which steps worked for me. But these are my steps to get rid of this error:

  1. Updated Node.js
  2. Ran npm cache clean command in Command prompt ( With some element of doubt for cache presence)
  3. Ran reactive-native init in command prompt as Administrator (on Windows OS), hoping works well with sudo reactive-native init on Mac OS

@7xrobin
Copy link

7xrobin commented Aug 1, 2016

npm cache clean fixed the issue for me too

@mkdonz
Copy link

mkdonz commented Aug 5, 2016

C:\xampp\htdocs\application>npm install npm -g
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "npm" "-g"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3

npm ERR! shasum check failed for C:\Users\user\AppData\Local\Temp\npm-7496-120e7f31\registry.npmjs.org\npm-\npm-3.10.5.tgz
npm ERR! Expected: 4753bfbb1526077d61c3b6a251cff61a22206cc6
npm ERR! Actual: 6e854f06f38ed2c4cde49a94189cc1a3b045b238
npm ERR! From: https://registry.npmjs.org/npm/-/npm-3.10.5.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! C:\xampp\htdocs\application\npm-debug.log

Can anyone assists me wit that error

@danielrf121
Copy link

NPM Cache Clean not work for me. I download old versions but It keeps happening the same error.

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "E:\nodejs\node.exe" "E:\nodejs\node_modules\npm\bin\npm-cli.js" "i"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8

I have even installed node in other directories outside the C: / and yet still the same problem.
Any fix for this?

Using windows 10.

@fawwaz
Copy link

fawwaz commented Sep 7, 2016

I still got a problem, npm cache clean does't work for me. i've run the program as administrator.

This will walk you through creating a new React Native project in E:\S2\for fun\belajar react\belajarreactnative\belajar
Installing react-native package from npm...

> [email protected] postinstall E:\S2\for fun\belajar react\belajarreactnative\belajar\node_modules\react-native\node_modules\yeoman-generator\node_modules\cross-spawn\node_modules\spawn-sync
> node postinstall


npm WARN peerDependencies The peer dependency react@~15.3.0 included from react-native will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead!
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Asus\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "react-native"
npm ERR! node v4.4.5
npm ERR! npm  v2.12.1
npm ERR! path C:\Users\Asus\AppData\Roaming\npm-cache\babel-runtime\6.11.6\package\package.json.e85a9ea0e36f7c5d62de3633a498cbbc
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Asus\AppData\Roaming\npm-cache\babel-runtime\6.11.6\package\package.json.e85a9ea0e36f7c5d62de3633a498cbbc' -> 'C:\Users\Asus\AppData\Ro
aming\npm-cache\babel-runtime\6.11.6\package\package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, rename 'C:\Users\Asus\AppData\Roaming\npm-cache\babel-runtime\6.11.6\package\package.json.e85a9ea0e36f7c5d62de3633a498cbbc' -> 'C:\Users\Asus\AppDat
a\Roaming\npm-cache\babel-runtime\6.11.6\package\package.json']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\Asus\\AppData\\Roaming\\npm-cache\\babel-runtime\\6.11.6\\package\\package.json.e85a9ea0e36f7c5d62de3633a498cbbc',
npm ERR!   dest: 'C:\\Users\\Asus\\AppData\\Roaming\\npm-cache\\babel-runtime\\6.11.6\\package\\package.json',
npm ERR!   parent: 'babel-plugin-transform-es2015-block-scoping' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\S2\for fun\belajar react\belajarreactnative\belajar\npm-debug.log

`npm install --save --save-exact react-native` failed

i am using windows 8.

@danielrf121
Copy link

I think I found my problem. I installed NPM still on windows 8.1 and it worked perfectly. I upgraded to Windows 10 and it was then that stopped working. This transition from Windows 8.1 to 10 that made something come out of the place with the NPM. I formatted my computer for windows 10 factory removing all programs. Installed all again and again NPM run beautifully. Who made this update windows, try formatting, the one that had something here.
Hug.

@Butterfly
Copy link

Hi! A question for those who had success with npm cache clean: Are you saying that you were then able to continue as your regular user? Are you saying you did not have to switch and become the root or admin user? It seems like an important detail that it wouldn't hurt for others to know. 😄

@stephensmith9
Copy link

stephensmith9 commented Jan 11, 2018

True for me, never had to switch to admin user (I used npm cache verify though).

virkt25 added a commit to loopbackio/loopback-next that referenced this issue Jan 31, 2018
@rahulswimmer
Copy link

I updated my node version to 8.9.4 and ran the necessary install command again from administrator command prompt. It worked for me!

@antonioaltamura
Copy link

antonioaltamura commented Feb 22, 2018

I periodically run into this issue and waste periodically 1-2 days on it.
Just google "EPERM error npm"..there are hundreds of thousands discussions.
I would pay money instead of be forced to use npm.

@rahulswimmer
Copy link

npm cache doesnt work for node versions 8.9.4. It says 'npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead'. In this case, what is the turnaround for 'npm cache clean'?

I guess one can try cleaning the cache using the --force flag, but isnt there are steady solution for this issue as it re appears in spate.

@OkGoDoIt
Copy link

OkGoDoIt commented Mar 6, 2018

I cannot disable the anti-virus at my work. Is there any other workaround people have found?

@antonioaltamura
Copy link

antonioaltamura commented Mar 6, 2018

Maybe I found a glimmer of light in this awful situation.
It look the problems are gone (I tried few packages) since I changed the npm directory from %appdata%/npm to C:\Program Files\nodejs

npm config set prefix "C:\Program Files\nodejs"

Maybe is just a coincidence, just give it a try.

@kubalakowski
Copy link

  1. Close your solution
  2. Delete all the content of your %project%/node_modules folder
  3. Run npm install as Administrator

Solved my issue. Give it a try.

@harisonde
Copy link

Disabling anti-virus resolved this issue for me.

@mustafa786786
Copy link

npm cache verify solved my problem

@ratherauqib
Copy link

I have same problem on Installing some npm Packages but I don't have any antivirus installed

I turned off Real-time protection and cloud delivered protection from windows defender and Reopens
the Terminal and it Worked for me.

@BoraxKid
Copy link

BoraxKid commented Apr 4, 2018

I don't know what specifically solved the issue for me but what I did was:

  • Downgraded to npm 5.0.3
  • npm cache verify
  • Close the terminal
  • Disable Malware Bytes and Windows Defenders
  • Open the PowerShell in admin mode

and npm install finally worked.

Hope this helps somebody.

I'm on Windows 10 64bits by the way.

@Robija
Copy link

Robija commented Apr 9, 2018

I can confirm the Antivirus case, specificaly the "Real-time protection" is the issue, in my case Malwarebytes.
Turn it off, clean the cache and install.

@ubercooluk
Copy link

The issue occurs either due to Antivirus software preventing the rename or permission issue w.r to user.

I have fixed it with the following command
execute npm config edit
look for the entry
cache-lock-retries=10

set the value to 1000 (or any bigger number)
cache-lock-retries=1000

@bigteejay
Copy link

I experienced this when I had a file in node_modules open (and edited) in Notepad++ (which doesn't usually preclude editing/deleting files and just notifies the user that a file is no longer on disk.) I saved the file elsewhere temporarily and closed it, then npm i completed without further issue.

@JasonKleban
Copy link

JasonKleban commented Jul 12, 2018

IMO this issue should be reopened. By my reading, npm v6 sounds like a big improvement in speed and reliability but this particular weakness is a total showstopper for moving back from yarn. Other programs scanning node_modules, such as anti-virus or VSCode or Atom Editor are locking up these files and causing very long-running npm operations to fail completely. yarn, in comparison, does not suffer these failures. Disabling antivirus, even selectively on node_modules, is arguably foolish, maybe even disallowed in some environments and certainly obnoxious. Quitting the editor, especially considering the integrated terminal of VSCode, is ridiculous.

The goal should be that NPM be resilient to brief file locks in the way that yarn has achieved, even if the case could be made that the other locking program is itself misbehaving in its use of locks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests