PS C:\Users\User> npx create-react-app client
Creating a new React app in C:\Users\User\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 Invalid response body while trying to fetch https://registry.npmjs.org/eslint: 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:\Users\User\AppData\Local\npm-cache\_logs\2022-04-18T02_58_18_148Z-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:\Users\User
Done.
npm ERR! code 1
npm ERR! path C:\Users\User
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-react-app "client"
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache\_logs\2022-04-18T02_58_06_939Z-debug-0.log
PS C:\Users\User>发布于 2022-07-11 10:08:24
在全球安装create时,npx create-react-app app-name和create-react-app app-name也遇到了同样的问题。
与纱线不同的是,npm对缓慢的互联网连接几乎没有容忍度。我甚至尝试使用来自终端的命令重置配置中的超时值属性:
npm config set timeout 240000还有,试过
npm config set fetch-retry-mintimeout 120000和
npm config set fetch-retry-maxtimeout 240000这些都不适合我。
最后,我通过简单地使用
yarn create react-app app-name纱在缓慢的连接上几乎不会失败,因为它总是尝试重新连接,并从停止的地方继续前进。
使用npm在全球范围内安装最新版本的纱线,使用:
npm i -g yarn@latest检查纱线是否已安装
yarn -v然后在所需的项目目录中运行yarn create react-app your-app-name。
发布于 2022-04-18 17:16:22
这对我有帮助
npm -g列表
安装-g创建-反应-应用程序
https://stackoverflow.com/questions/71912097
复制相似问题