[英]having an issue creating new react app with create-react-app
我正在嘗試創建一個新的 React 項目,但是當我運行npx create-react-app tik-tok-clone
出現以下錯誤
Creating a new React app in C:\Users\mwars\Documents\GitHub\TikTok-Clone\tik-tok-clone.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error postcss@8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact react react-dom react-scripts cra-template --cwd C:\Users\mwars\Documents\GitHub\TikTok-Clone\tik-tok-clone has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting tik-tok-clone/ from C:\Users\mwars\Documents\GitHub\TikTok-Clone
Done.
我一直試圖弄清楚它現在已經有一段時間了,但無法讓它發揮作用。
我正在處理同樣的問題,並設法理解並修復它。 我將在下面嘗試解釋它。
問題:
error postcss@8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
這告訴您create_react_app
模塊僅與版本10
、 12
或大於14
的node
兼容,並且您使用的是13.12.0
。
解決方案
要修復此錯誤,您需要升級或降級當前版本的node
。
一種方法是使用NVM
(節點版本管理器)來管理node
多個版本。
要在 Linux 或 Mac 上安裝它,您可以使用以下任一命令
對於 Wget,請在終端上運行以下命令:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
對於 CURL,運行以下命令:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
您需要將命令中的版本號更改為最新的穩定版本。
成功下載后重新啟動終端,否則您將無法找到它。 如果此操作失敗,您可能需要重置計算機。
如果您安裝了NVM
運行以下內容應該會顯示您使用的當前版本。
nvm --version
然后,您可以使用以下命令列出節點的可用版本
nvm ls-remote
選擇兼容版本並像這樣安裝
nvm install 14.15.0
跑步
node -v
如果不嘗試,應該將其顯示為您當前的版本
nvm use v14.15.0
你現在應該沒有問題了
npx create-react-app tik-tok-clone
運行這些命令后,它對我有用。
sudo npm cache clean -f //清除你的npm緩存
sudo npm install -gn install n //(這可能需要一段時間)
sudo n stable upgrade //到當前的穩定版本
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.