Build error on Vercel

JavaScript
back
March, 2024
2 min read

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.

Andris Švarcs

Somehow, I've survived over 15 years as a web developer without losing my interest in the craft. Quite the opposite, with so many great improvements in the Web standards, what was nearly impossible now is easy to make.

My career has been a wild ride through small agencies and big corporations, building everything from finance apps to health dashboards.

I'm that annoying person who needs to understand products beyond just slinging code. I ask questions like 'Why is this feature important?' and 'How will this improve the customer journey?' – you know, the kind of questions that make project managers reach for the pint aspirin. This curiosity has led me down the rabbit holes of design, accessibility, and SEO. Because apparently, making websites pretty, usable, and findable wasn't challenging enough on its own.

P.S. If this bio sounds too polished, blame my evil AI twin. I'm still working on teaching it sarcasm.

Copyright © since 2021, Andris Švarcs. All rights reserved.

Lets connect

bluesky

youtube

linkedin