Mic*_*sky 4 npm reactjs create-react-app npx
我正在尝试创建一个新的反应项目,但是当我运行时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.
Run Code Online (Sandbox Code Playgroud)
我一直试图弄清楚它现在已经有一段时间了,但无法让它发挥作用。
我正在处理同样的问题,并设法理解并修复它。我将在下面尝试解释它。
问题:
error postcss@8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
Run Code Online (Sandbox Code Playgroud)
这是告诉你的是,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
Run Code Online (Sandbox Code Playgroud)
对于 CURL,运行以下命令:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Run Code Online (Sandbox Code Playgroud)
您需要将命令中的版本号更改为最新的稳定版本。
成功下载后重新启动终端,否则您将无法找到它。如果此操作失败,您可能需要重置计算机。
如果您已NVM安装,运行以下内容应该会显示您使用的当前版本。
nvm --version
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用以下命令列出节点的可用版本
nvm ls-remote
Run Code Online (Sandbox Code Playgroud)
选择兼容版本并像这样安装
nvm install 14.15.0
Run Code Online (Sandbox Code Playgroud)
跑步
node -v
Run Code Online (Sandbox Code Playgroud)
如果不尝试,应将其显示为您当前的版本
nvm use v14.15.0
Run Code Online (Sandbox Code Playgroud)
你现在应该没有问题了
npx create-react-app tik-tok-clone
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1060 次 |
| 最近记录: |