create-react-native-app: Error: EPERM: operation not permitted, rename

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.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 35 (4 by maintainers)

Most upvoted comments

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!

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

@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

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

@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!

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.

It seems to be the Node.js issue https://github.com/isaacs/node-graceful-fs/issues/104#issuecomment-335495181 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 https://github.com/isaacs/node-graceful-fs/pull/119

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

thanks @johnnyreilly! nice post