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-plugin-jsx-a11y: 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! /home/purushot/.npm/_logs/2021-12-07T08_23_28_234Z-debug-0.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.npm版本为8.0.2
节点版本为16.13.1
ubuntu版本为20.04.3
可以在这里查看完整日志,https://codepen.io/purushot-frontend/pen/OJxNPgQ
更新:无法找到确切原因,但回滚到节点版本12.22.7,NPMv6.14.15及其再次工作。
发布于 2021-12-07 08:56:06
这似乎是一个缓慢的互联网连接问题。通过将此添加到.npmrc文件中,尝试将超时时间从30到60增加:
如果您想节省带宽或连接速度慢,您也可以尝试添加“timeout=60000-脱机=true”。
注意:如果您还没有.npmrc文件设置,可以在这里创建一个
对于Windows: C:\Users{username}.npmrc for Mac/Linux ~/..npmrc,或者您可以在与项目的package.json文件相同的目录中创建一个。
发布于 2021-12-07 09:44:31
在使用npx create-react-app创建一个react应用程序时,我也面临着同样的问题。我通过运行以下命令解决了我的问题。
npm cache clean --force然后
npx create-react-app [app-name]https://stackoverflow.com/questions/70257202
复制相似问题