[英]having an issue creating new react app with create-react-app
I am trying to create a new react project, but when I run npx create-react-app tik-tok-clone
I get the following error我正在尝试创建一个新的 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.
I've been trying to figure it out for a while now and just can't get it to work.我一直试图弄清楚它现在已经有一段时间了,但无法让它发挥作用。
I am was dealing with the same problem and have managed to understand and fix it.我正在处理同样的问题,并设法理解并修复它。 I will try to explain it below.
我将在下面尝试解释它。
The issue:问题:
error postcss@8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
This is telling you that the create_react_app
module is only compatible with versions 10
, 12
, or greater than 14
of node
and you are using 13.12.0
.这告诉您
create_react_app
模块仅与版本10
、 12
或大于14
的node
兼容,并且您使用的是13.12.0
。
The solution解决方案
To fix this error you need to either upgrade or downgrade your current version of node
.要修复此错误,您需要升级或降级当前版本的
node
。
One way to do this is to use NVM
(node version manager) to manage multiple versions of node
.一种方法是使用
NVM
(节点版本管理器)来管理node
多个版本。
To install it with either Linux or Mac you can use either of the following commands要在 Linux 或 Mac 上安装它,您可以使用以下任一命令
For Wget, run the following command on the terminal:对于 Wget,请在终端上运行以下命令:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For CURL, run the following:对于 CURL,运行以下命令:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
You will want to change the version number in the commands to the latest stable version.您需要将命令中的版本号更改为最新的稳定版本。
Once you have downloaded it successfully restart the terminal or you won't be able to find it.成功下载后重新启动终端,否则您将无法找到它。 If this fails you may need to reset your computer.
如果此操作失败,您可能需要重置计算机。
If you have NVM
installed running the following should show you the current version of it your using.如果您安装了
NVM
运行以下内容应该会显示您使用的当前版本。
nvm --version
You can then use the following command to list available versions of node然后,您可以使用以下命令列出节点的可用版本
nvm ls-remote
Select a compatible version and install it like so选择兼容版本并像这样安装
nvm install 14.15.0
Running跑步
node -v
Should show this as your current version if not try如果不尝试,应该将其显示为您当前的版本
nvm use v14.15.0
You should now have no issues running你现在应该没有问题了
npx create-react-app tik-tok-clone
It worked for me after running these commands.运行这些命令后,它对我有用。
sudo npm cache clean -f //clear you npm cache sudo npm cache clean -f //清除你的npm缓存
sudo npm install -gn install n //(this might take a while) sudo npm install -gn install n //(这可能需要一段时间)
sudo n stable upgrade //to the current stable version sudo n stable upgrade //到当前的稳定版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.