簡體   English   中英

我在創建 React 應用程序時遇到問題

[英]I am having trouble with creating react app

我試圖創建一個新的 React 項目,但我遇到了在我嘗試npm 緩存清理之前從未見過的錯誤 --force它說npm WARN using --force Recommended protections disabled。 所以我試過了

npm 緩存驗證它響應

it Cache verified and compressed (~\AppData\Local\npm-cache\_cacache)
Content verified: 0 (0 bytes)
Index entries: 0
Finished in 0.013s

但我仍然無法使用命令 npx create-react-app projectName 創建 React 應用程序

它只是回應

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/html-entities reason: Invalid response body while trying to fetch https://registry.npmjs.org/html-entities: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\u4\AppData\Local\npm-cache\_logs\2023-01-04T11_43_21_180Z-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 travel/ from C:\Users\u4\Desktop\code
Done.

我更新了我的節點,認為這可能是問題所在,但仍然沒有改變幫助!!

所以我找到了問題的根源。 首先我運行了 npm -g list它只有npm沒有 create-react-app 所以你需要使用npm install -g create-react-app安裝它。 通過運行npm -g list檢查它是否成功安裝了 create-react-app 將是他們的。 現在你可以毫無問題地運行 npx create-react-app projctname。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM