如何解决 create-react-app 的问题?

how to solve problem with create-react-app?

npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch 
https://registry.npmjs.org/@typescript-eslint%2fscope-manager: 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! A complete log of this run can be found in:
npm ERR!     C:\Users\nurlan\AppData\Local\npm-cache\_logs21-11-17T07_07_31_258Z-debug.log

听起来你的连接速度很慢。通过将此添加到您的 .npmrc 文件,尝试将超时从 30 秒增加到 60 秒:

timeout=60000

您也可以尝试添加

prefer-offline=true

如果您正在尝试节省带宽或连接速度较慢

注意:如果您还没有 .npmrc 文件设置,您可以在此处创建一个

  • 对于 Windows:C:\Users\{username}\.npmrc
  • 对于 Mac/Linux ~/.npmrc

或者您可以在与项目的 package.json 文件相同的目录中创建一个。