'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.
Solution 1:[1]
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
Solution 2:[2]
Try this:
npm install -g npm@latest
npm install node
npm install -g yarn
yarn cache clean
npx create-react-app my-app
Solution 3:[3]
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).:
- 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.
- tar warning
[email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Solution 4:[4]
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!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nishant Bage |
| Solution 2 | John Emerson |
| Solution 3 | VinĂcius Cerqueira Bonifácio |
| Solution 4 | Jyotika Grover |
