当我想创建一个 React 应用程序时,我遇到了以下错误:
npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms) npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\info\AppData\Roaming\npm-cache\_logs\2020-04-23T02_54_45_865Z-debug.log Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed. Deleting generated file... package.json Deleting app2/ from C:\Users\info Done.
最佳答案
听起来你的连接速度很慢。通过将此添加到您的 .npmrc
中,尝试将超时从 30 秒增加到 60 秒。文件:
timeout=60000
您也可以尝试添加
prefer-offline=true
如果您正在尝试节省带宽或连接速度较慢
注意:如果您没有
.npmrc
文件设置,你可以在这里创建一个C:\Users\{username}\.npmrc
~/.npmrc
或者您可以在与项目的
package.json
相同的目录中创建一个文件。
关于reactjs - npm 错误!尝试获取 https ://registry. npmjs.org/react-is 时响应超时(超过 30000 毫秒),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61378672/