javascript 安装React时出现NPM错误

jm81lzqq  于 2022-12-17  发布在  Java
关注(0)|答案(1)|浏览(239)

我正在安装React.js,我得到了这个错误.
我安装了react应用程序,但我发现这个错误。

PS D:\Other\Youtube Channels\Design,tuts and motivational  channels\Code with harry\Website course\Test folder> npx create-react-app my-react-app 

Creating a new React app in D:\Other\Youtube Channels\Design,tuts and motivational  channels\Code with harry\Website course\Test folder\my-react-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code FETCH_ERROR 
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/@typescript-eslint%2feslint-plugin reason: Invalid response body while trying to fetch https://registry.npmjs.org/@typescript-eslint%2feslint-plugin: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\amanullah\AppData\Local\npm-cache\_logs\2022-12-15T09_57_58_961Z-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 my-react-app/ from D:\Other\Youtube Channels\Design,tuts and motivational  channels\Code with harry\Website course\Test folder
Done.
PS D:\Other\Youtube Channels\Design,tuts and motivational  channels\Code with harry\Website course\Test folder>

我看了一些yt的视频,甚至stackoverflow的对话,但我没有找到任何答案。
我期待在网站的文件夹中安装React应用程序。但我得到了错误

ar5n3qh5

ar5n3qh51#

这是由于套接字超时,换句话说,你的网络速度太慢,无法下载资源或花费太多时间,并且引发错误。你可以通过重置超时持续时间来解决此问题。
重置最小超时:

npm config set fetch-retry-mintimeout 100000 // time in milliseconds

或重置最大超时:

npm config set fetch-retry-maxtimeout 200000 // time in milliseconds

相关问题