Soham Kamble
Soham Kamble

Reputation: 11

I am not able to install Create React App (CRA) on my MacBook Pro M1

How can I fix this error?

I ran the following command on iTerm2 after installing Node.js and adding it into the path.

npm install -g create-react-app

I get the following error:

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amaterasu/.npm/_logs/2022-01-04T08_36_06_018Z-debug.log ```

Upvotes: 1

Views: 4420

Answers (4)

JIGNESH PATEL
JIGNESH PATEL

Reputation: 397

Create one folder for React projects. Open that folder in the terminal (commandline). And use npx create-react-app yourAppName .

The above error is permission-related. You don’t have permissions to create a new folder under "/usr/local/lib/node_modules/create-react-app".

If this error still comes, use sudo npx create-react-app yourAppName.

Upvotes: 0

Shubhra Kushal
Shubhra Kushal

Reputation: 309

You need to have Node.js version 14 (or greater) and npm 5.6 (or greater).

Use the command npx create-react-app myapp.

Upvotes: 0

Mohale
Mohale

Reputation: 2230

I ran into this earlier today and here is how I fixed it.

  1. npm uninstall -g create-react-app
  2. npx clear-npx-cache
  3. npx create-react-app my-app

If you are interested on the details regarding this issue, than have a look at this github thread

Upvotes: 4

Shayan Faghani
Shayan Faghani

Reputation: 240

For the npm packages you want to install globally, mainly you may encounter permission problems. This can usually be solved by adding sudo at the first of the line. So instead of:

create-react-app yourAppName

You can do this:

sudo npx create-react-app yourAppName

Following your root user password.

Also, to add more, there are some reported problems with the node js version and create react app. you can check the version of node installed in your Mac, by this command at your terminal:

node --version

if the installed version of the Node is 17.X, it can be assumed it is related to the problem.

It is always recommended to use the LTS version.

enter link description here

Upvotes: 1

Related Questions