[Vercel] Upgrading Node.js.

I received an email from Vercel saying ‘[Action Required] Node.js 18 is being discontinued on Monday, September 1st, 2025’.

With the end of support for Node.js 18 on 30/4/2025, I received a notice that the environment running on Node.js 18 in Vercel will also be unavailable. Upgrade, it said.

https://vercel.com/docs/functions/runtimes/node-js/node-js-versions#setting-the-node.js-version-in-project-settings

Since I was using the Vercel environment in Next.js, I decided to upgrade to Node.js 18 to 22.x.

When support ends, security patches will no longer be provided at all, and bug fixes and performance improvements will not be made, so the risks in terms of safety and stability will increase, so this is essential if you want to operate properly.

目次

Upgrade the Vercel environment from Node.js 18.x to 22.x

The work can be divided into three main steps: 1) preparing the local development environment, 2) changing and updating project settings, and 3) checking and deploying the project.

Set the Node.js version of the local development environment to 22.x

advance preparation

We create a new branch in Git before we start working on it, so that we can quickly revert back to the original state in case of any problems.
We also use the Preview function in Vercel, which is useful because it creates a Preview environment at the time of a Pull Request.

# checkout main
git checkout main

# Get the latest status of the Git repository.
git pull

# Create a new branch for Node.js upgrades and switch
git checkout -b feature/upgrade-node-22

Upgrade Node.js in the development environment

Upgrade the Node.js environment in the development environment – this is convenient if you use nvm or similar, but my environment is Mac and I used Node.js in /usr/local/bin/node, so it was a bit of a pain.

Change this to use nodebrew before upgrading.

Set the nodebrew path correctly.

Execute the following command to write the nodebrew path settings to the ~/.zshrc file.

echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.zshrc

Reflect the configuration in the terminal. (Restart the terminal to ensure that it is reflected.)

source ~/.zshrc

Set the version to be used by nodebrew.

nodebrew use v22.17.0

Check the Node.js version, making sure it is v22.17.0.

node -v

Updating and versioning of dependent packages

Add engines to package.json to tell Vercel to use Node.js 22.

{
  // ...
  "engines": {
    "node": "22.x"
  },
  // ...
}

Use npm-check-updates (ncu) to keep project dependencies up-to-date.
This is useful, but it can be difficult to track down the cause of any errors, so it is recommended to check package updates one at a time.

npx npm-check-updates -u

To eliminate inconsistencies in the environment, remove all packages and caches once and reinstall in a clean state.

rm -rf .next node_modules yarn.lock

yarn cache clean

yarn install

Checking local operation

Yarn dev locally and check that all pages work without errors.
Check for deprecated methods due to package upgrades and errors due to eslint updates.

Finally, run yarn build to check that the build passes.

yarn dev

yarn build

Fix GitHub Actions workflow.

Fix the yaml (.github/workflows/*.yml) defined for automatic deployment to Vercel in GitHub Actions.
Add actions/setup-node@v4 so that the CI environment is also Node.js v22.x.

steps:
  - uses: actions/checkout@v2

  # Add this step.
  - name: Setup Node.js
    uses: actions/setup-node@v4
    with:
      node-version: '22.x'

  - name: Install Vercel CLI
  ...

GitHubActions in Vercel is described in the following article.

Push changes and create PRs.

Commit all changes to Git, push to GitHub and create a PullRequest.

At this point, CI will fail because the Vercel environment has not been upgraded. As written later, we will perform the ‘Upgrade the Vercel environment from Node.js 18.x to Node.js 22.x’, which will be described later in advance.

git add .

git commit -m "feat: Upgrade to Node.js 22 and apply necessary fixes"

git push origin feature/upgrade-node-22

Check operation with the Preview version of Vercel.

Once the CI is running, it is automatically deployed as a Preview version in Vercel.
Access the Preview version in Vercel under Deployments -> Options (3-point reader) -> Visit. Check that it works and make sure there are no problems.

Upgrade the Vercel environment from Node.js 18.x to Node.js 22.x

From the Vercel dashboard, go to the relevant project page and click Settings -> Build and Deployment.

[Under Node.js Version, update from 18.x to 22.x.

Update to 22.x.

If you don’t do this, an error will occur during PR. If this is not done, an error will occur during PR.

If the following errors occur during PR,

Run vercel build --token=***
Vercel CLI 44.5.0
WARN! Build not running on Vercel. System environment variables will not be available.
Warning: Due to "engines": { "node": "22.x" } in your `package.json` file, the Node.js Version defined in your Project Settings ("18.x") will not apply, Node.js Version "22.x" will be used instead. Learn More: http://vercel.link/node-version
Installing dependencies...
yarn install v1.22.22
[1/5] Validating package.json...
error kyoto-sanjo-degital-map@0.1.0: The engine "node" is incompatible with this module. Expected version "22.x". Got "20.19.3"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Command "yarn install" exited with 1
Error: Process completed with exit code 1.

Version up Vercel and re-run the job. OR empty commit and make it work.

Deploy to Production.

Merge the PR you have created as you have defined a yaml (.github/workflows/*.yml) for automatic deployment to Vercel in GitHub Actions.

Check that the Status is Ready in Vercel’s Deployments, and if it seems to be working OK, the Node.js upgrade is complete.

シェア!

この記事を書いた人

kenichiのアバター kenichi エンジニア・写真家 | Engineer and photographer

Nomadic worker who travels all over Japan and abroad; worked as a technical sales person for five years before going independent.
Works as a freelance engineer on website production and application development. Currently working to bring interesting things by interesting people to the world, while seeking to move abroad.

目次