Create-react-app: Error: EPERM: operation not permitted, mkdir 'C:\Users\Vaidehi' TypeError: Cannot read property 'get' of undefined

Created on 30 May 2020  路  34Comments  路  Source: facebook/create-react-app

Im trying to create a react app using command create-react-app and getting the error of,
Screenshot (114)

MY COMMAND: (using . as i want to create the app in the current folder itself)

C:\Users\Vaidehi Shah\Desktop\MERN-ShoppingListclient> npx create-react-app .

ERROR MESSAGE:

Error: EPERM: operation not permitted, mkdir 'C:\Users\Vaidehi'
TypeError: Cannot read property 'get' of undefined
at errorMessage (C:\Program Filesnodejs\node_modules\npm\libutils\error-message.js:38:39)
at errorHandler (C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:201:13)
at C:\Program Filesnodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Filesnodejs\node_modules\npm\lib\npm.js:225:22)
at C:\Program Filesnodejs\node_modules\npm\lib\npm.js:263:24
at C:\Program Filesnodejs\node_modules\npm\lib\config\core.js:81:7
at Array.forEach ()
at C:\Program Filesnodejs\node_modules\npm\lib\config\core.js:80:13
at f (C:\Program Filesnodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Filesnodejs\node_modules\npm\lib\config\core.js:171:20)
C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:97
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^

TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:97:27)
at process.errorHandler (C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:216:3)
at process.emit (events.js:210:5)
at process._fatalException (internal/process/execution.js:150:25)
Install for [ 'create-react-app@latest' ] failed with code 7

Most helpful comment

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 helps :)

All 34 comments

I got this same!

I got this error, when I run the same command

Error: EPERM: operation not permitted, mkdir 'C:\Users{USER_NAME}'
command not found: create-react-app

Bruh Same
Error: EPERM: operation not permitted, mkdir 'C:\Users{USER_NAME}'
command not found: create-react-app

i think it's because the user names has a character space " ", been trying to change the folder name and even user with local users and groups but it made things worse

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 helps :)

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 helps :)

Thank you, it's working ;)

yes its working

yeah it's working.

@ambekar92 and @Sahithi-Venkatesan Thank you both of them.
Yeah it's working properly.

thank you, its working

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 helps :)

Thank you so much, It works

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 5 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\ThembaA~1\AppData\Roaming\npm-cache this will solve the issue

this one worked for me.

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 helps :)

Please note this method might work but it is not the preferred method to solve this issue according to the create-react-app formal documentation we must not install this module globally. running the command npm install -g create-react-app will install create-react-app and the documentation advises us to avoid this and instead uninstall the package globally (by running npm uninstall -g create-react-app) and then resort to using npx. I have attached a picture below supporting my statement from the create-react-app documentation page: https://github.com/facebook/create-react-app . Please see my comment above highlighting the correct way to solve this issue.
npx preferred

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 helps :)

thanks ,it is working

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

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 helps :)

OMG you helped a noob like me, thanks a lot

@dhioputro
This is not the recommended way of using create-react-app according to the React documentation and it may cause problems down the line.|

Same happened with me. I did the same, installed create-react-app globally and it started working but after a few days and a few tweaks and a few updates here and there it stopped working again.

After having to spend 2 hours digging I found this to be the more permanent solution.

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

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 helps :)

Thank you so much, It works

yeah it works fine. Thanks

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

Thanks. This resolved the issue.

muio obrigado! funcionou bastante.

@ Sahithi-Venkatesan
lots of thanks

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 helps :)

You save me

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

Thanks so much. This resolved the issue for me

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case, since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

Yeah, this is one way to get the short name. But you don't have to look for it all the time. By default, this is 6 letters followed by ~1. In my case, changing ABHI TRIPATHI to ABHITR~1 worked. Notice there are 6 letters. Since the Firstname is only 4 letters long so it also includes 2 letters of Lastname. Maybe the firstname you used was 5 letters long.

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 helps :)

It worked. But what was the issue and how did your suggestion resolve it?

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 helps :)

It worked. But what was the issue and how did your suggestion resolve it?

This method of resolving the problem is not recommended. Refer to other solutions mentioned above and try to resolve it.
You can visit this https://create-react-app.dev/docs/getting-started/ to know why it's not recommended.

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 helps :)

THANK YOU MS @Sahithi-Venkatesan IT WORKS FOR ME NOW HEHEHE sorry for the caplocks

@dhioputro
This is not the recommended way of using create-react-app according to the React documentation and it may cause problems down the line.|

Same happened with me. I did the same, installed create-react-app globally and it started working but after a few days and a few tweaks and a few updates here and there it stopped working again.

After having to spend 2 hours digging I found this to be the more permanent solution.

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

So I tried doing this and my system is not showing any shortnames, I'm still not able to fix this! Can you help me out?

Im trying to create a react app using command create-react-app and getting the error of,
Screenshot (114)

MY COMMAND: (using . as i want to create the app in the current folder itself)

C:\Users\Vaidehi Shah\Desktop\MERN-ShoppingListclient> npx create-react-app .

ERROR MESSAGE:

Error: EPERM: operation not permitted, mkdir 'C:\Users\Vaidehi'
TypeError: Cannot read property 'get' of undefined
at errorMessage (C:\Program Filesnodejs\node_modules\npm\libutils\error-message.js:38:39)
at errorHandler (C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:201:13)
at C:\Program Filesnodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Filesnodejs\node_modules\npm\lib\npm.js:225:22)
at C:\Program Filesnodejs\node_modules\npm\lib\npm.js:263:24
at C:\Program Filesnodejs\node_modules\npm\lib\config\core.js:81:7
at Array.forEach ()
at C:\Program Filesnodejs\node_modules\npm\lib\config\core.js:80:13
at f (C:\Program Filesnodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Filesnodejs\node_modules\npm\lib\config\core.js:171:20)
C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:97
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^

TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:97:27)
at process.errorHandler (C:\Program Filesnodejs\node_modules\npm\libutils\error-handler.js:216:3)
at process.emit (events.js:210:5)
at process._fatalException (internal/process/execution.js:150:25)
Install for [ 'create-react-app@latest' ] failed with code 7

Same here....

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 helps :)

Thank You so much Sahithi mam it helps a lot

This error is caused by having a space in your User name (i.e the name of your machine) for instance my machine name is Themba Alex, npx has an issue when such is the case, the solution to this is to open your terminal and run this command:
npm config edit afterward go to every line that is starting with
;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache, remove the ; and remove the space on your username, write the first 6 letters and add "~1" i.e ;cache=C:\Users\Themba Alex\AppData\Roaming\npm-cache will now be cache=C:\Users\Themba~1\AppData\Roaming\npm-cache this will solve the issue

After a lot of digging and coming to this, I thought this would solve my problem but it isn't solving my problem. Even after changing Firstname Lastname to Firstname~1 and to Firstname~Lastname I am getting the same error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~Lastname' command not found: create-react-app

I found the solution to this. Instead of just changing Firstname Lastname to Firstname~1 or Firstname~Lastname , check what the short name for your Username directory is. You can do this by opening the CMD as an administrator and running dir /x in the parent folder of the folder whose short name you're trying to find. In this case since you want to know the short name to your Firstname Lastname folder, the parent folder will be C:/Users. So go to C:/Users and run dir /x. You'll find the short name of your Firstname Lastname folder. It may not necessarily be Firstname~1. In my case, it was FirstnameL~1. After this you can run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global. Now you should be able to run npx create-react-app my-app without any issue.

Thanks so much. This resolved the issue for me

Thank you, this one worked for me. The shortname was written in all caps and using dir /x helped.

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 helps :)

thank u

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 helps :)

thank u.. command works...

Was this page helpful?
0 / 5 - 0 ratings