Build error on Vercel

I’m a front-end developer and not very fancy on the server side. That being said, I spent some ten years managing my own Linux on DigitalOcean with WP blogs. When I say managing, it was more like doing some updates and maintenance only.

Then, I discovered SvelteKit, which was when I finally decided to go wild with my own blog.

So far, I am enjoying my ride until suddenly, after doing minor updates, I got this error on Vercel.

1
Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:
2
  node_modules/node-fetch/lib/index.js
3
    - encoding
4
  ✔ done
5
✓ built in 12.25s
6
Build Completed in /vercel/output [22s]
7
Deploying outputs...
8
Error: The following Serverless Functions contain an invalid "runtime":
9
  - fn (nodejs18.x). Learn More: https://vercel.com/guides/serverless-function-contains-invalid-runtime-error
10

What is going on? All I did, was to change an image in one of the posts. I double checked, that there are no any changes in package nor lock files.

Luckily, after some discussion on Mastodon it hit me!

In my package.json I use

1
"engines": {
2
    "node": ">=18.0.0"
3
},

I guess, Vercel some days ago added Node v.20 as well. So, it automatically build project with the latest Node and that broke the build.

For now I set it to version 18 like so

1
"engines": {
2
    "node": ">=18.18.0 <19.0.0"
3
},

Hopefully this will give a hint for somebody else for similar error in Vercel.