如何解决此错误 jest-worker@27.0.0-next.5:引擎"node"与此模块不兼容


linix@linix-HP-ProBook-6475b:~/projects/builds$ npx create-next-app hellochat
npx: installed 1 in 2.333s
Creating a new Next.js app in /home/linix/projects/builds/hellochat.
Installing react, react-dom, and next using yarn...
yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error jest-worker@27.0.0-next.5: The engine "node" is incompatible with this module. Expected version "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0". Got "14.5.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 next --cwd /home/linix/projects/builds/hellochat has failed.
linix@linix-HP-ProBook-6475b:~/projects/builds$ 

您应该能够通过更新节点来解决问题。

Windows:

只需从这里从Windows中的.msi重新安装节点。

适用于Ubuntu或Linux/Mac:

  • 安装模块n以简化版本管理:

sudo npm install n -g

  • 对于最新的稳定版本:

sudo n stable

  • 对于最新版本:

sudo n latest

在我的案例中,我在Dockerfile中偷偷添加了一个apt update,这使系统知道了更新。最好的做法是严格控制版本。例如,使用'packageName': '1.0.0'而不是'packageName':'latest'

我能够通过删除apk update并将我的node:alpine版本升级为node:alpine3.13来解决问题。

相关内容

最新更新