如何解决这个错误 jest-worker@27.0.0-next.5:The engine "node" is incompatible with this module

问题描述

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:

只需从 here 的 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 来解决。