create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

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

Open vaidehishah07 opened this issue 6 years ago • 123 comments

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-ShoppingList\client> 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 Files\nodejs\node_modules\npm\lib\utils\error-message.js:38:39) at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:201:13) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7 at Array.forEach () at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13 at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25) at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:171:20) C:\Program Files\nodejs\node_modules\npm\lib\utils\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 Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27) at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\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

vaidehishah07 avatar May 30 '20 01:05 vaidehishah07

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

Sierra-034 avatar Jul 01 '20 03:07 Sierra-034

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

DarkDenims avatar Jul 01 '20 06:07 DarkDenims

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

Sahithi-Venkatesan avatar Jul 03 '20 12:07 Sahithi-Venkatesan

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 ;)

ambekar92 avatar Jul 04 '20 08:07 ambekar92

yes its working

gagandeepchauhan avatar Jul 29 '20 16:07 gagandeepchauhan

yeah it's working.

benittobeny34 avatar Jul 31 '20 18:07 benittobeny34

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

wakidur avatar Aug 04 '20 07:08 wakidur

thank you, its working

hassanqamar90 avatar Aug 09 '20 14:08 hassanqamar90

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

sandyivan avatar Aug 11 '20 09:08 sandyivan

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

AnkhEl avatar Aug 11 '20 21:08 AnkhEl

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.

kiranimeid avatar Aug 12 '20 09:08 kiranimeid

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

AnkhEl avatar Aug 12 '20 13:08 AnkhEl

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

KapilShukla88 avatar Aug 21 '20 06:08 KapilShukla88

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

VicodinAbuser avatar Aug 22 '20 16:08 VicodinAbuser

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.

VicodinAbuser avatar Aug 22 '20 17:08 VicodinAbuser

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 avatar Aug 24 '20 13:08 dhioputro

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

VicodinAbuser avatar Aug 24 '20 17:08 VicodinAbuser

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

manish-iitg avatar Aug 25 '20 18:08 manish-iitg

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.

m-bandari avatar Sep 05 '20 10:09 m-bandari

muio obrigado! funcionou bastante.

henrique-stack avatar Oct 01 '20 12:10 henrique-stack