当我使用 npm 创建 React 应用程序时,出现此错误
when I use npm to create react app ,I get this error
我在使用 npm 时遇到问题,我无法创建 React 应用程序
当我执行 npm init react-app my-app
或 npx create-react-app my-app
时,我收到此错误
C:\Users\ZAKARIA\Desktop\react1>npm init react-app my-app
Creating a new React app in C:\Users\ZAKARIA\Desktop\react1\my-app.
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! network 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\ZAKARIA\AppData\Local\npm-cache\_logs22-01-12T09_37_00_926Z-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... node_modules
Deleting generated file... package.json
Deleting my-app/ from C:\Users\ZAKARIA\Desktop\react1
Done.
npm ERR! code 1
npm ERR! path C:\Users\ZAKARIA\Desktop\react1
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-react-app "my-app"
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ZAKARIA\AppData\Local\npm-cache\_logs22-01-12T09_36_53_140Z-debug-0.log
知道如何解决这个问题
您可以尝试使用此命令清理缓存npm cache clear --force
然后重试。
我在使用 npm 时遇到问题,我无法创建 React 应用程序
当我执行 npm init react-app my-app
或 npx create-react-app my-app
时,我收到此错误
C:\Users\ZAKARIA\Desktop\react1>npm init react-app my-app
Creating a new React app in C:\Users\ZAKARIA\Desktop\react1\my-app.
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! network 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\ZAKARIA\AppData\Local\npm-cache\_logs22-01-12T09_37_00_926Z-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... node_modules
Deleting generated file... package.json
Deleting my-app/ from C:\Users\ZAKARIA\Desktop\react1
Done.
npm ERR! code 1
npm ERR! path C:\Users\ZAKARIA\Desktop\react1
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-react-app "my-app"
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ZAKARIA\AppData\Local\npm-cache\_logs22-01-12T09_36_53_140Z-debug-0.log
知道如何解决这个问题
您可以尝试使用此命令清理缓存npm cache clear --force
然后重试。