我正在嘗試使用 npm 創建一個 React 專案,但我失敗了,因為不再支持 npm-create-react 的全域版本,但即使我按照告訴我的操作,它也不起作用。當我嘗試使用命令時
npm init react-app my-app
我從控制臺收到此錯誤
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
npm ERR! code 1
npm ERR! path /Users/nick/Documents/NFT
npm ERR! command failed
npm ERR! command sh -c create-react-app "my-app"
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nick/.npm/_logs/2022-02-26T08_47_03_397Z-debug.log
收到此錯誤后,我鍵入命令
npm uninstall -g create-react-app
并在終端中列印以下訊息:
up to date, audited 1 package in 110ms
found 0 vulnerabilities
在這之后沒有任何改變,我仍然得到同樣的錯誤。我怎樣才能洗掉這個?先感謝您。
uj5u.com熱心網友回復:
嘗試像這樣從 npx 運行創建反應應用程式
npx create-react-app app-name
uj5u.com熱心網友回復:
我通過使用此命令使其作業
npm install -g create-react-app@5.0.0
然后我可以再次使用
npx create-react-app app-name
uj5u.com熱心網友回復:
您需要在您的機器上安裝 Node >= 14.0.0 和 npm >= 5.6。要創建專案,請運行:
npx create-react-app my-app
cd my-app
npm start
檔案鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/435501.html
