3

I am trying to setup a ReactJS app on Windows using the following command:

npx create-react-app my-app

and the output is coming as :

PS C:\Users\santu\React-JS> npx create-react-app my-app
node:fs:1349
  handleErrorFromBinding(ctx);
  ^

Error: EPERM: operation not permitted, mkdir 'my-app'
    at Object.mkdirSync (node:fs:1349:3)
    at Object.module.exports.makeDirSync (C:\Users\santu\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\make-dir.js:23:13)    
    at createApp (C:\Users\santu\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:257:6)
    at C:\Users\santu\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:223:9
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  errno: -4048,
  syscall: 'mkdir',
  code: 'EPERM',
  path: 'my-app'
}
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Santu Dhali
  • 31
  • 1
  • 2
  • Are you running as a non administrator account? That message means your account doesn't have write permissions in the directory you are working in. or maybe you are in the wrong directory – Krishnadev. V Aug 03 '22 at 06:05
  • You can also find answers in this [post](https://stackoverflow.com/questions/55450386/npm-eperm-mkdir-operation-not-permitted-on-windows). – Kelvin Aug 03 '22 at 06:08
  • Visit: https://stackoverflow.com/questions/34600932/npm-eperm-operation-not-permitted-on-windows – shashank sah Aug 03 '22 at 06:31
  • @Krishnadev.V, @Kelvin, that looks a bit weird. Creating a folder in `C:\Users\santu\React-JS` shouldn't require admin privileges unless the OP was not using `santu` to run the command. Also, the path doesn't contains any weird characters or spaces – Matthew Kwong Aug 03 '22 at 06:42

3 Answers3

1

Solution 1

To make this run..You need to run my cmd as an administrator.

So run the below commands:

Run cmd as administrator
Run npm config edit (You will get notepad editor)
Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
Then npm start works in a normal console.

OR

Solution 2

Try installing it globally first, using the command

npm install -g create-react-app

And then, you can create your app using the command,

npx create-react-app <Name of your app>

Hope this will help.

Edit: Above solution might work but it's not recommended way of solving this issue. Please refer the Link

I referred to the solution given at the bottom, also some other posts to use the below too:

command: npm config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global
Sumit Munot
  • 3,748
  • 1
  • 32
  • 51
-2

try to update your npm Using npm@latest command to update the node package manager.

npm install npm@latest -g

after updating your package try

npx create-react-app my-app

you should be able to run without any issues

Krishnadev. V
  • 345
  • 2
  • 8
  • 23
-2

Run your cmd as administrator or Run vs code as administrator