Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npx create-react-app myapp command throwning error

Tags:

reactjs

I wanted to create an app in react . I have installed the latest Node js when I am running the command I am getting error

The following error is coming.

PS C:\Users\Kumar Sanket\Desktop\React&Redux> npx create-react-app myapp Error: EEXIST: file already exists, mkdir 'C:\Users\Kumar' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) 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:228:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7 at Array.forEach () at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82: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:173:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205 if (npm.config.get('json')) { ^

TypeError: Cannot read property 'get' of undefined at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at process.emit (events.js:189:13) at process._fatalException (internal/bootstrap/node.js:496:27) Install for create-react-app@latest failed with c

like image 898
kumar sanket Avatar asked Nov 28 '22 13:11

kumar sanket


1 Answers

Today I encountered a similar issue with npx create-react-app my-app(mkdir failed).

Reason for my error

  1. I had space in my user name folder(ex: Abc Xyz) and thus "npx" couldn't refer to it correctly (It only read Abc, and not Xyz).

  2. I am using VS Code for React, and it didn't had the permission to create new directory

How I fixed it

  1. Opened VS Code with Administrator rights.(fixed permission issue)

  2. Instead of using "npx" I tried the following:

    --> npm install -g create-react-app

    --> create-react-app my-app

And that got executed successfully.

Hope this helps.

like image 105
Malhar Desai Avatar answered Dec 05 '22 03:12

Malhar Desai