Skip to content
This repository has been archived by the owner. It is now read-only.

Error: EPERM: operation not permitted, rename #191

Closed
Darper opened this issue May 5, 2017 · 34 comments

Comments

Projects
None yet
@Darper
Copy link

commented May 5, 2017

Description

Getting windows rename error when attempting to run create-react-native-app myApp

Expected Behavior

Following setup instructions, I installed create-react-native-app globally then attempted to create a new project. I have done this on Mac with no problem, but Windows returns a series of "operation not permitted" errors

Observed Behavior

$ create-react-native-app drrug
Creating a new React Native app in C:\dev\training\drrug.

Installing packages. This might take a couple minutes.
Installing react-native-scripts...

npm WARN deprecated @exponent/spawn-async@1.2.8: Please switch to @expo/spawn-async, the new name of this package. It's the same code with our new name.
drrug@0.1.0 C:\dev\training\drrug
+-- babel-runtime@6.23.0  extraneous
+-- cross-spawn@5.1.0  extraneous
+-- fs-promise@1.0.0  extraneous
+-- indent-string@3.1.0  extraneous
+-- inquirer@3.0.6  extraneous
+-- match-require@2.1.0  extraneous
+-- minimist@1.2.0  extraneous
+-- path-exists@3.0.0  extraneous
+-- progress@2.0.0  extraneous
`-- qrcode-terminal@0.11.0  extraneous

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "--save-exact" "react-native-scripts"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path C:\dev\training\drrug\node_modules\.staging\@exponent\ngrok-fc327f2a
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\dev\training\drrug\node_modules\.staging\@exponent\ngrok-fc327f2a' -> 'C:\dev\training\drrug\node_modules\@exponent\ngrok'
npm ERR!     at destStatted (C:\Users\dharper\AppData\Roaming\nvm\v6.9.1\node_modules\npm\lib\install\action\finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\dev\training\drrug\node_modules\.staging\@exponent\ngrok-fc327f2a' -> 'C:\dev\training\drrug\node_modules\@exponent\ngrok'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\dev\training\drrug\node_modules\.staging\@exponent\ngrok-fc327f2a' -> 'C:\dev\training\drrug\node_modules\@exponent\ngrok'
npm ERR!     at destStatted (C:\Users\dharper\AppData\Roaming\nvm\v6.9.1\node_modules\npm\lib\install\action\finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\dev\training\drrug\node_modules\.staging\@exponent\ngrok-fc327f2a' -> 'C:\dev\training\drrug\node_modules\@exponent\ngrok'
npm ERR!     at Error (native) parent: 'drrug' }
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:\dev\training\drrug\npm-debug.log
`npm install --save-dev --save-exact react-native-scripts` failed

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-scripts:
    `-- (empty)

npm ERR! code 1

  • npm ls react-native:
    `-- (empty)

npm ERR! code 1

  • npm ls expo:
    `-- (empty)

npm ERR! code 1

  • node -v: v6.9.1
  • npm -v: 3.10.8
  • yarn --version: bash: yarn: command not found
  • watchman version: bash: watchman: command not found

Also specify:

  1. Operating system: Windows 7
  2. Phone/emulator/simulator & version: N/A

Reproducible Demo

App wouldn't setup, so no demo except for above stack trace.

@Sofiane-13

This comment has been minimized.

Copy link

commented May 15, 2017

You have found the problem ?

@anp

This comment has been minimized.

Copy link
Member

commented May 22, 2017

Are you able to install other npm-based projects in this directory? Do you have any antivirus that would prevent these files from being moved around? I'm not sure why you wouldn't have permission to rename the file, but this seems to me like a Windows/npm issue?

@Darper

This comment has been minimized.

Copy link
Author

commented May 25, 2017

I've never had a problem with any other NPM projects in the past. I know that this is probably unique to my system, but I was hoping somebody would have seen the same issue. create-react-app works fine, but create-react-native-app still has the errors above.

@fmeira

This comment has been minimized.

Copy link

commented May 25, 2017

I got the same problem just doing an npm install.
Run with antivirus disabled (if you use Windows Defender, turn off Real-Time protection and Cloud-based protection). That worked for me!

@brentvatne

This comment has been minimized.

Copy link
Member

commented Jun 2, 2017

I'll assume that @fmeira's suggestion works and close this! If anyone has a solution for how we can just have this work out of the box for people with the same configuration as you folks then please open a PR or an issue with the idea!

@johnnyreilly

This comment has been minimized.

Copy link

commented Jun 11, 2017

@fmeira solution worked for me as well - it looks like Windows Defender has started to get more aggressive of late?! I've blogged about it to try and let others know - so strange... https://blog.johnnyreilly.com/2017/06/windows-defender-step-away-from-npm.html

@brentvatne

This comment has been minimized.

Copy link
Member

commented Jun 12, 2017

thanks @johnnyreilly! nice post

@fedesardo

This comment has been minimized.

Copy link

commented Jul 18, 2017

I run npm install -g npm and also npm install and it did not work for me! Still unable to install using npm using command like this: ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID=xxxxxxxxx --save in my visual studio code. Any idea?

@Simoneth

This comment has been minimized.

Copy link

commented Jul 19, 2017

Here is my try: https://github.com/drhouse7/react-native-try

On Win8.1 I turned off Windows Defender Real-Time protection (I set also an exclusion to my node.exe path) however get this:

npm ERR! path C:\projects\combined\node_modules\.staging\es5-ext-c47e8e2a
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\projects\combined\nod
e_modules\.staging\es5-ext-c47e8e2a' -> 'C:\projects\combined\node_modules\es5-e
xt'
@kunokdev

This comment has been minimized.

Copy link

commented Jul 21, 2017

Hi, I am getting EPERM error when running npm start after fresh app initialization.
My environment is: Node 6.11.1 npm ~v3 , Ubuntu shell on Windows 10

@brentvatne

This comment has been minimized.

Copy link
Member

commented Jul 25, 2017

these links may be helpful:

alas this is not a create-react-native-app issue but a npm issue

@brentvatne brentvatne reopened this Jul 25, 2017

@brentvatne brentvatne closed this Jul 25, 2017

@bleuscyther

This comment has been minimized.

Copy link

commented Jul 27, 2017

Close any Node.Js process and retry with a new prompt window

@ofirDubi

This comment has been minimized.

Copy link

commented Jul 27, 2017

@bleuscyther worked for my, i had my react app running while i was trying to download react-navigation.

@NULL-SWEAT

This comment has been minimized.

Copy link

commented Aug 2, 2017

I has having this problem at a university win7 machine.
Solved by disabling the anti-virus and on a new cmd prompt run npm cache verify

@hmafzal

This comment has been minimized.

Copy link

commented Aug 3, 2017

@johnnyreilly thanks for the post and the bug report on VS Code! It ended up being VS Code for me too. Updating to 1.14 fixed the issue!

@johnnyreilly

This comment has been minimized.

Copy link

commented Aug 3, 2017

Awesome @hmafzal!

@afturner

This comment has been minimized.

Copy link

commented Aug 3, 2017

This also happens for those that have their project directory within a Box sync folder. Perhaps with other services like Dropbox or Google Drive. Pausing the sync fixed the issue immediately.

@Spyrology

This comment has been minimized.

Copy link

commented Aug 7, 2017

Had this issue with create-react-app. Turning off anti-virus (Trend Micro) and running npm cache clean didn't work. Then ran npm cache verify and tried again (with anti-virus still off) - voila! Don't know whether npm cache verify alone would've sufficed in my instance, but thanks @fmeira and @NULL-SWEAT!

@jmmclean

This comment has been minimized.

Copy link

commented Aug 8, 2017

I had this issue w/ a different module, but figured i'd comment here. My fix was upgrading node & npm (specifically npm) using nvm:
Old npm: 3.10.10
New npm: 5.3.0

Working now.

@apatti

This comment has been minimized.

Copy link

commented Aug 18, 2017

Upgrading the npm using npm install -g npm as resolved the issue for me.

@tijsdeboeck

This comment has been minimized.

Copy link

commented Aug 22, 2017

@afturner indeed, same for Dropbox, paused syncing fixed the issue...

@sharad2803

This comment has been minimized.

Copy link

commented Aug 31, 2017

I got the same error,
"Error: EPERM: operation not permitted, scandir" after running with # npm i , and also not authorized to stop antivirus option (window defender) so tried to run separately in cmd or cmder instead of code editor @Terminal, it works for me.

@prageethmadhu

This comment has been minimized.

Copy link

commented Sep 12, 2017

After huge struggle found the solution for me .. 👍

"Create new folders"
mkdir E:\Buildagent\npm
mkdir E:\Buildagent\npm-cache

"move npm prefix and the cache"
robocopy c:\Users\the-build-user\AppData\Roaming\npm E:\Buildagent\npm
robocopy c:\Users\the-build-user\AppData\Roaming\npm-cache E:\Buildagent\npm-cache /E /MOVE

"Update the npm config for prefix and cache"
npm config set prefix E:\Buildagent\npm
npm config set cache E:\Buildagent\npm-cache

https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/

@rahulcreace

This comment has been minimized.

Copy link

commented Sep 19, 2017

Closing the project in expo XDE before installing solved my problem

@chetmurphy

This comment has been minimized.

Copy link

commented Sep 23, 2017

Instead of turning off Windows Defender Real-Time protection I just set a folder exclusion.

@apollocoder

This comment has been minimized.

Copy link

commented Sep 26, 2017

I get the error with npm 5.4 but not with npm 5.3. Maybe try this:

npm -g i npm@5.3

This does not seem to be an issue with create-react-app. I got the same problem with other apps as well.

@vladimiry

This comment has been minimized.

Copy link

commented Nov 23, 2017

It seems to be the Node.js issue isaacs/node-graceful-fs#104 (comment) That would explain that such weird workaround as same for Dropbox, paused syncing fixed the issue... prevents issue happening, because probably there is no high concurrent access to the same files anymore after stopping file system scanning by Dropbox (antiviruses, whatever).

There are many issues on GitHub placed regarding the EPERM problem and looks like most of such issues just go to the "closed" state without the actual resolution. You can see more details here isaacs/node-graceful-fs#119

@EwanBd

This comment has been minimized.

Copy link

commented Apr 6, 2018

We had this issue writing files from node to a remote server. We upgraded from v 0.12.2 to 8.10.0 and this began occurring, So we ran 'node cache verify' and it cleared the problem.

@pashute

This comment has been minimized.

Copy link

commented Apr 25, 2018

Solved!! Turn off react-native. npm install, which will now work, and restart react-native. That's all.

I had the same problem. I couldn't understand why it told me to re-run from a cmd with admin permissions, while I was running with admin. Turned out that you have to close the running react-native-cli (which I had started with yarn start in a different admin-cmd window. )

So maybe to close this issue also add that to the user message. Something like: Close the react-native-cli or retry the installation from a command window with administrator permissions.

@timsar2

This comment has been minimized.

Copy link

commented Apr 27, 2018

try to add full permission on npm folder
C:\Users\YourAccount_Aame\AppData\Roaming
just right click on npm and from security tab add full permison to your user account or add everyone(if security is not important) then set full permision to everyone.

@Neonit Neonit referenced this issue May 4, 2018

Open

npm install gives error -4048 #19956

1 of 4 tasks complete
@Uzairrrr

This comment has been minimized.

Copy link

commented Jun 20, 2018

I got the same problem just doing an npm install --save react-navigation
Run with antivirus disabled (if you use Windows Defender, turn off Real-Time protection and Cloud-based protection).
Worked for me.

@mockingloris

This comment has been minimized.

Copy link

commented Jun 24, 2018

@johnnyreilly thanks... had the same issue.
All I did was close VS Code and re-ran the command; that did the trick, no errors.

@neihcnim

This comment has been minimized.

Copy link

commented Jul 30, 2018

In windows 10, I don't see real time protection under windows defender. However, I see it under my antivirus software. Turning it off, the problem goes away.

@harshadduasane

This comment has been minimized.

Copy link

commented Aug 1, 2018

@fmeira thanks, your suggestion works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.