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

4
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$ 

1
你尝试过升级到 Node.js 14.15.x 吗?因为错误提示表明该模块与您当前使用的节点版本 (14.5.0) 不兼容。 - juliomalves
2个回答

1
您可以通过更新node来解决问题。
对于Windows:
只需从这里重新安装Windows中的.msi中的node。
对于Ubuntu或Linux / Mac:
安装模块n以使版本管理更容易:
sudo npm install n -g
对于最新稳定版本:
sudo n stable 对于最新版本:
sudo n latest

0
在我的情况下,我在Dockerfile中偷偷加入了一个apt update,这使得系统意识到更新。最好的做法是保持版本严格。例如,使用'packageName': '1.0.0'而不是'packageName':'latest'
我通过删除apk update并升级我的node:alpine版本到node:alpine3.13来解决问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接