A Next.js project was built on one PC. A partner clones it on theirs, runs npm run dev, and it stops before the first page. Their Node.js version is different, and Next.js checks it before it does anything else.

I tested it on Windows 11 with a fresh Next.js 16.3.3 app. I ran it on Node 18, 22 and 24, then in Docker. This post shows the exact error, the three lines that stop the problem coming back, and what Docker does and does not fix. Docker also has one hot-reload trap that cost me most of the testing time.

Which Node.js version does Next.js 16 need?

Next.js 16 needs Node.js 20.9.0 or newer. You don't have to guess: it is written in the package itself. Open node_modules/next/package.json and look for the engines field:

"engines": { "node": ">=20.9.0" } 

Older lines needed less. Next.js 14 and 15 ran on Node 18.18 or newer, which is why a project started a year ago can run on a machine where a new one fails. Node 20 itself reached end of life in April 2026, so for a team today the sensible pick is Node 22 or 24. Both are LTS, and both worked in my tests.

What happens on the wrong version: the exact error

I downloaded the portable Node 18.20.8 zip from nodejs.org, checked its SHA-256, and ran the dev server with it:

> next dev -p 3210 You are using Node.js 18.20.8. For Next.js, Node.js version ">=20.9.0" is required. 

The exit code was 1. The check sits at the top of next/dist/bin/next, so it fails within a second. It also blocks next build and next start. If your partner sees this message, nothing is wrong with the code. They need a newer Node.

A newer version is not a problem in the other direction. The same project ran on Node 24.22.3: the dev server was ready in 5 seconds and returned HTTP 200, and next build completed. The PC that created it had Node 22.17.1. So "different version" only matters when it is below the minimum, or when a package with native code was built for one version and used with another.

One trap from my own testing. In Git Bash on Windows, PATH="C:/node18:$PATH" node -v printed v22. The colon in C: splits PATH, so the switch silently did nothing, and my first "Node 18 works fine" result was really Node 22. Use /c/node18 in Git Bash. Always run node -v before trusting a version test.

Fix 1: write the version into the project

The real problem is that the right version lives only in someone's head. Put it in the repository, where every machine can read it. Three small additions do this.

.nvmrc: the version to use

22 

That is the whole file. Version managers such as nvm (Mac and Linux) and fnm read it. Your partner runs nvm install and then nvm use inside the project folder, and gets the right Node without asking anyone. Writing 22 instead of 22.17.1 lets everyone take the latest patch release. Pin the full version only if you need byte-identical builds.

engines in package.json: the version to refuse

"engines": { "node": ">=20.9.0" } 

On its own, this only warns. On Node 18, npm install printed npm warn EBADENGINE Unsupported engine and still finished with exit code 0. Warnings scroll past, so add a one-line .npmrc next to package.json:

engine-strict=true 

With it, both npm install and npm ci stopped on Node 18 with exit code 1:

npm error code EBADENGINE npm error notsup Not compatible with your version of node/npm: demo@0.1.0 npm error notsup Required: {"node":">=20.9.0"} npm error notsup Actual: {"npm":"10.8.2","node":"v18.20.8"} 

Now the mistake shows up at install time with a clear message. Without it, it shows up later as a broken dev server. Commit all three: the .nvmrc file, the engines field and the .npmrc file.

Fix 2: let the partner switch Node versions

Your partner may need their old Node for another project. Uninstalling it is the wrong answer. A version manager keeps several versions side by side and switches per project:

  • nvm on Mac and Linux: nvm install, then nvm use. It reads .nvmrc.
  • nvm-windows: a separate project with the same name. Run nvm install 22 and nvm use 22 explicitly, and do not rely on it reading .nvmrc.
  • fnm: works on Windows, Mac and Linux, reads .nvmrc and can switch automatically when you cd into the folder.
  • Volta: pins the version inside package.json itself.

I did not install these managers for this post. My version tests used portable Node zips, which work too: download, unzip, and put the folder first on PATH for one terminal. For a quick "does it run on 24?" check, that is the least invasive method, because nothing is installed and the system Node is untouched.

How Docker helps: the Node version ships with the project

Version files and managers still depend on each person setting up their own machine. Docker removes that step. The Node version is written in the Dockerfile, and the container brings its own Node, whatever is installed on the PC. In my test the PC had Node 22.17.1, and the container reported v22.23.5 from the node:22-alpine image. Your partner needs only Docker Desktop.

For development, the code stays on the partner's disk and is mounted into the container so edits show up live. This is the setup I tested. Dockerfile.dev:

FROM node:22-alpine WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci COPY . . EXPOSE 3000 CMD ["npm", "run", "dev", "--", "-H", "0.0.0.0"] 

compose.yaml:

services: web: build: context: . dockerfile: Dockerfile.dev ports: - "3000:3000" environment: - WATCHPACK_POLLING=true command: ["npx", "next", "dev", "--webpack", "-H", "0.0.0.0"] volumes: - .:/app - /app/node_modules - /app/.next 

And a .dockerignore with node_modules, .next and .git, so the build does not copy Windows-built packages into a Linux image. The two extra volume lines keep the container's own node_modules and .next, so the host folder does not overwrite them. Then:

docker compose up --build 

The first build took about a minute and a half, mostly downloading the image and running npm ci. After that the page answered with HTTP 200. On my PC port 3000 was already taken by another dev server, and Docker refused to start with ports are not available ... bind: Only one usage of each socket address. Map a different host port, such as "3300:3000", if you see that. If the busy port is another Next.js server, see "Another next dev server is already running".

-H 0.0.0.0 matters. Without it the dev server listens only inside the container, and the browser on the host gets nothing.

The trap: hot reload does not work in Docker on Windows

This is why the compose file above says --webpack and WATCHPACK_POLLING. With the plain default setup, the page loaded but never changed when I edited a file. The container could see the new file content, but Next.js never recompiled. Files edited on Windows and mounted into the Linux container do not send the change events the watcher waits for.

The fix is polling: the watcher checks files on a timer instead of waiting for events. I edited app/page.tsx on Windows and timed how long the page took to show the change:

Setup (Docker Desktop 4.99, Windows 11) Edit picked up?
Turbopack (the Next 16 default), no polling No, waited 16 s
Turbopack + watchOptions.pollIntervalMs: 1000 No, waited 30 s
next dev --webpack, no polling No, waited 16 s
--webpack + WATCHPACK_POLLING=true Yes, about 4 s
--webpack + watchOptions.pollIntervalMs: 1000 Yes, about 2 s
Turbopack, code inside the container (no bind mount) Yes, about 2 s
Control: Turbopack directly on Windows, no Docker Yes, about 2 s

Next 16 does pass pollIntervalMs to Turbopack; I found it in the dev server source. But in my test it did not make bind-mounted edits reload, not even edits made from inside the container. Webpack with polling worked every time. So for development in Docker on Windows, run the dev server with --webpack and turn polling on. If you prefer the config file to the environment variable:

// next.config.ts const nextConfig = { ...(process.env.DOCKER_DEV === "1" && { watchOptions: { pollIntervalMs: 1000 } }), }; 

The condition keeps polling off outside Docker, where it would only waste CPU. The last rows of the table point to the other way out: keep the code on a Linux filesystem, where file events work. With VS Code that means the WSL2 filesystem or a Dev Container. I did not test those two here, but the "no bind mount" row behaved the same way.

Docker for production: a smaller image

The dev image is big: 1.32 GB, because it holds every dev dependency. For running the app, set output: "standalone" in next.config.ts and use a multi-stage build that copies only what the server needs:

FROM node:22-alpine AS deps WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci FROM node:22-alpine AS build WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build FROM node:22-alpine AS run WORKDIR /app ENV NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0 RUN addgroup -S app && adduser -S app -G app COPY --from=build --chown=app:app /app/.next/standalone ./ COPY --from=build --chown=app:app /app/.next/static ./.next/static COPY --from=build --chown=app:app /app/public ./public USER app EXPOSE 3000 CMD ["node", "server.js"] 

This image came out at 333 MB, a quarter of the dev image. It started in milliseconds and returned HTTP 200. It also runs as a non-root user. The rebuild took about 40 seconds with the dependency layer already cached. One thing to watch: anything starting with NEXT_PUBLIC_ is baked in during npm run build, so it must be available at build time, not only when the container starts. Something similar caught this site once with .env.local overriding .env.production.

So which should your partner use?

  • Just running it once to have a look: install Node 22 or 24 (or unzip a portable one) and run npm ci, then npm run dev.
  • Working on it regularly, alongside other projects: a version manager plus the .nvmrc, engines and engine-strict files. This is the lightest setup, and hot reload works natively.
  • Several people, or a project with native packages, or you deploy with containers anyway: Docker. Everyone gets the same Node and the same Linux packages. On Windows, remember the polling setting.

Whichever you pick, commit the version files. They cost three lines and turn a confusing broken dev server into a clear error at install time. If Docker is new to you, the Docker tutorial covers images, containers and volumes from the start.

Originally published on KnowledgeMarkG.