reactjs - 使用 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
推荐阅读
- php - 自动将教练分配给成员
- keras - keras 上的多 GPU 训练错误(OOM)(内存足够,可能是配置问题)
- python - Python & Unittest 在第一次测试完成并且测试失败后打开第二个浏览器
- typescript - 打字稿:使用错误的参数计数没有警告
- grunt-contrib-connect - 使用 grunt-contrib-connect 服务本地主机时如何删除端口号“:80”
- c - 使用 luarocks 安装 hdf5 时出现 hdf5.h 错误
- benchmarkdotnet - 如何在 BenchmarkDotNet 中对同一非 NuGet 库的两个不同版本进行基准测试?
- wpf - 为什么 Resource 样式不适用于 Separator 而是直接应用的样式作品?
- c# - 正则表达式替换排除第一个和第 n 个字符
- python - 在 python 中练习语音识别时,麦克风不会自行关闭