NextJS or Node Compatability Error

I’m attempting to launch a pages application using NextJS from a git project. When attempting the build, I am greeted with the following:

22:19:11.112	[2/4] Fetching packages...
22:19:27.741	error [email protected]: The engine "node" is incompatible with this module. Expected version ">=12.22.0". Got "12.18.0"
22:19:27.751	error Found incompatible module.

From my understanding, this is either referring to my NextJS version or my Node version. I have the latest version of each installed and am unsure on how to proceed.

For reference, here is my dependencies and devDependencies from my package.json

"dependencies": {
        "@popperjs/core": "@^2.11.5",
        "bootstrap": "^5.2.0",
        "html-react-parser": "^3.0.1",
        "next": "^12.2.5",
        "path-exists": "^5.0.0",
        "react": "^18.2.0",
        "react-bootstrap": "^2.5.0",
        "react-calendar": "^3.7.0",
        "react-dom": "^18.2.0",
        "react-scroll-parallax": "^3.3.1",
        "typescript": "^2.8.0"
    "devDependencies": {
        "eslint": "8.22.0",
        "eslint-config-next": "12.2.5"

Any and all help would be appreciated

Cloudflare Pages uses an older version of Node by default (12), which is causing your issue. You will need to set the NODE_VERSION env var to something like 16 to install a newer version.

Do note that NextJS support is pretty limited today with Pages (only really supporting static export), but I know that work is actively happening at the moment to get more NextJS features running on Pages, like SSR.

1 Like

Do you have a more detailed way of doing this? As far as I’m aware, the changes need to be made to the package.json file or yarn.lock file, both of which I don’t think can accept a simple env variable. I’ve attempted the following addition to my package.json file, but no luck:

"engines": {
        "node": ">=12"

Try setting the NODE_VERSION environment variable in your Pages dashboard for your project: Build configuration · Cloudflare Pages docs

This way, you are telling Pages to use Node 16 instead of the default 12, which looking at your errors is too old.

Here’s another resource:

Next.js requires Node.js v12.22.0 or later to build successfully. To set your Node version, go to Settings in your Workers project > Environment Variables (advanced) section and add a NODE_VERSION variable with a value of 12.22.0 or greater.

This solved it, thank you!


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.