Sam
Sam

Reputation: 31

Error when I run npx create-react-app my-app

I have tried these two commands and am getting the same error.

npm clean cache --force
npx create-react-app client -timeout=120000


$ npx create-react-app client -timeout=120000
npm WARN exec The following package was not found and will be installed: create-react-app
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

Creating a new React app in C:\web_dev\MERN\projects\booking-app\client.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network request to https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz failed, reason: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\web_dev\MERN\projects\booking-app\tmpnodejsnpm-cache\_logs\2021-12-29T13_37_03_989Z-debug-0.log

Aborting installation.
  npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting client/ from C:\web_dev\MERN\projects\booking-app
Done.

Upvotes: 1

Views: 6138

Answers (6)

Chammi Hansana
Chammi Hansana

Reputation: 1

You should try using a different network, either a different Wi-Fi network or using a mobile hotspot. Then, try again to create the react app: npx create-react-app <project_name>.

Hope this should help you.This Works For me.

Upvotes: 0

Adewale Ologbenla
Adewale Ologbenla

Reputation: 1

I had the same error sometime ago, just make sure you don't have any space between the name of your directories folders like Desktop/react project/my-react-app ...this is wrong try this Desktop/reactproject/my-react-app ... correction

Upvotes: 0

Jyotika Grover
Jyotika Grover

Reputation: 21

Even I was getting the same error and then saw your question I closed all the task and run this command "npx create-react-app my-app" again it got solved!

Upvotes: 1

I have just faced the same issue when upgrading an old project. What solved, in my case was:

  • If you use yarn:
yarn global remove create-react-app
yarn cache clean
  • If you use npm:
npm remove create-react-app
npx clear-npx-cache

Also make sure there is no folder in the directory where you will created the new React project because you can get another warning similar to:

The directory . contains files that could conflict:

  <the file(s) name here>/

Either try using a new directory name, or remove the files listed above.

After that, npx create-react-app . ran smoothly.

Those steps described above solved the following subsequent warnings (versions may vary).:

  1. Global warning
You are running "create-react-app" 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
  1. tar warning
[email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

Upvotes: 1

John Emerson
John Emerson

Reputation: 27

Try this:

npm install -g npm@latest
npm install node
npm install -g yarn
yarn cache clean
npx create-react-app my-app

Upvotes: 0

Nishant Bage
Nishant Bage

Reputation: 5

I had the same problem so I uninstalled it globally then reinstall:-

  • npm uninstall -g create-react-app
  • npm uninstall create-react-app

Then I used npx:-

  • npx create-react-app project-app

Tell me if this works for you

Upvotes: 0

Related Questions