我已经尝试过这两个命令,并且得到了相同的错误。
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 tar@2.2.2: 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.发布于 2022-02-19 14:11:16
我刚刚在更新一个旧项目时也遇到了同样的问题。在我的案子中,解决的是:
如果使用yarn,则
yarn global remove create-react-app
yarn cache clean如果使用npm,则
npm remove create-react-app
npx clear-npx-cache另外,请确保目录中没有创建新React项目的文件夹,因为您可以得到另一个类似于以下内容的警告:
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.在那之后,npx create-react-app .跑得很顺利。
上述步骤解决了以下后续警告(版本可能有所不同):
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@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.发布于 2022-05-29 07:12:15
甚至我也得到了同样的错误,然后看到你的问题,我关闭了所有的任务,并运行这个命令"npx创建-反应-应用程序我的应用程序“,它再次解决了!
发布于 2021-12-29 14:39:25
我也有同样的问题,所以我在全球范围内卸载它,然后重新安装:-
create-react-app
然后我用npx:-
告诉我这个对你有用吗?
https://stackoverflow.com/questions/70520786
复制相似问题