[英]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.