簡體   English   中英

React Js,npx create-react-app 上未提供模板<app name></app>

[英]React Js, Template Not Provided On npx create-react-app <app name>

我正在使用

npx create-react-app <app name>

並且收到未提供模板的錯誤,請執行以下操作->

npx uninstall -g create-react-app

好吧,我已經做到了,但沒有幫助。 我已經嘗試更新當前的 nodejs 和 npm 版本,我已經完成了 nodejs 的全新安裝,並且我已經清除了 npm 和 npx 緩存。 我也嘗試過使用特定的 create-react-app 版本,例如

npx create-react-app@latest(or some other version)

沒有任何效果,沒有提供任何模板,我有點迷茫。 有誰知道另一種潛在的解決方法? 如果存在這樣的事情,我願意手動下載包含 npx create-react-app 完成后內容的文件夾。

React 文檔指出您可能通過 Yarn 而不是 NPM 安裝了create-react-app ,也可以試試這個:

yarn global remove create-react-app

這個 SO 答案表明,如果npm uninstall -g create-react-app不起作用,您可以手動查看是否可以安裝create-react-app以及在何處安裝。

如果npm uninstall -g create-react-app不起作用。 輸入which create-react-app以了解它的安裝位置。 我的安裝在/usr/bin文件夾中。 然后執行sudo rm -rf /usr/bin/create-react-app

您使用的是 Windows 還是 Mac/Linux? which命令適用於 Mac/Linux,但不適用於 Windows。 我不知道在 Windows 上執行此操作的最佳方法,但該線程對 PowerShell 有一些建議。

我對 npx 命令的理解是它偽安裝了npx (在本例中為create-react-app ),以確保我們使用的是最新可用的。 它方便且推薦,但不是必需的。 如果您仍然遇到問題,我會親自嘗試完全安裝create-react-app以查看是否可以通過這種方式構建新項目:

npm install -g create-react-app
create-react-app my-app

暫無
暫無

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

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