Error when using create-react-app in node.js on Windows 7 64-bit

2

I have installed node.js and receive an error when using the following command:

create-react-app <folder name>

The output is:

Creating a new React app in C:\Users\Desktop\my-react-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...


> uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\Desktop\my-react-app\n
ode_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm ERR! path C:\Users\Desktop\my-react-app\node_modules\nan\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Desktop\my
-react-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, unlink 'C:\Users\Desktop
\my-react-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'C:\\Users\\Desktop\\my-react-app\\node_modules\\nan\\package.json\'\n    at Error (nati
ve)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\Desktop\\my-react-app\\node_modules\\nan\\pac
kage.json' }
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\AppData\Roaming\npm-cache\_logs\2017-09-07T11_17_31_8
99Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts
 has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting my-react-app / from C:\Users\Desktop
Done.

The problem persists when running as administrator:

Your environment has been set up for using Node.js 6.11.3 (x64) and npm.

C:\Windows\System32>npm install -g create-react-app
C:\Users\amar\AppData\Roaming\npm\create-react-app -> C:\Users\amar\AppData\R
ing\npm\node_modules\create-react-app\index.js
+ create-react-app@1.4.0
updated 1 package in 17.296s

C:\Windows\System32>create-react-app react-app

Creating a new React app in C:\Windows\System32\react-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...


> uglifyjs-webpack-plugin@0.4.6 postinstall C:\Windows\System32\react-app\nod
odules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm ERR! path C:\Windows\System32\react-app\node_modules\nan\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Windows\System32\r
t-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, unlink 'C:\Windows\System3
eact-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'C:\\Window
System32\\react-app\\node_modules\\nan\\package.json\'\n    at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Windows\\System32\\react-app\\node_modules\\nan\\packag
son' }
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\amar\AppData\Roaming\npm-cache\_logs\2017-09-07T17_16_1
06Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scri
 has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting react-app / from C:\Windows\System32
Done.

C:\Windows\System32>

amar

Posted 2017-09-07T11:31:05.700

Reputation: 21

So what happens when you run it as root/Administrator? – mtak – 2017-09-07T12:02:04.020

1First of all, path C:\USERS\DESKTOP probably doesn't exist. You must put your currently logged-in username between users and desktop. – Kitet – 2017-09-07T13:22:07.810

Now you’ve created a third account! Get your accounts merged, and put information about your problem into your question, where it belongs. – Scott – 2017-09-08T03:09:21.060

Answers

0

It's a pity that you left out path - that's probably the culprit.

This error message indicates that npm doesn't have permissions to perform some file operation:

npm ERR! Please try running this command again as root/Administrator.

This could happen when running npm install -g <something> (installing something globally), but for local installs it usually indicates your mistake in path.

And indeed, the path from 2nd line looks off:

Creating a new React app in C:\Users\Desktop\my-react-app.

Your username is missing! C:\Users contains user profiles, which contain Desktop folders. So the path should be C:\Users\YourUsername\Desktop\my-react-app.

gronostaj

Posted 2017-09-07T11:31:05.700

Reputation: 33 047

By your deleted answer and attempt to edit my answer I suppose that you didn't get what I typed here. You DON'T have to run it as administrator because you're not doing a global install. You have to fix the path you're entering to include your username. – gronostaj – 2017-09-08T07:34:28.980

I have the same issue, as he is running "create-react-app <folder name>" he does not have the ability to "change the folder name" it should create the React Application automatically in the containing folder. @amar try disabling Anti-virus and Dropbox...I now get past the error, but it freezes at: extract:for-in: sill pacote for-in@https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz extracted in 35850ms

– galgo – 2017-09-13T22:11:00.913