"Function Runtimes must have a valid version" Error Despite V2 Config

Hello Vercel Community,

I’m consistently getting the error Error: Function Runtimes must have a valid version, for example \now-php@1.0.0`.despite myvercel.jsonbeing configured withversion: 2and a valid Node.js runtime (e.g.,nodejs18.x`).

Issue:
My local vercel -d logs consistently show that when a deployment is created, Vercel’s API responds with "config":{"version":1} in the deployment details, even though my vercel.json clearly specifies "version": 2 causing the runtime definition to be rejected.

What I’ve Tried (All Resulted in the Same Error):

  1. Original Project (frontend-quiz-app-main):

    • vercel.json:
      {
        "version": 2,
        "functions": { "api/**/*.js": { "runtime": "nodejs18.x" } }
      }
      
      (This project’s vercel.json was also tested with nodejs20.x with the same error results).
    • api/gemini-chat.js:
      export const config = { runtime: 'nodejs18' };
      
      (This function is for a Gemini chatbot API).
    • Vercel Dashboard Node.js Version (Build Environment): Set to 18.x (also tried 20.x when vercel.json was nodejs20.x).
    • Failed Deployment Inspect URL: https://vercel.com/jay-laycos-projects/frontend-quiz-app-main/Cyo25teCvZdW7kS7j3mn3VYyEa9d?filter=errors
    • (Project ID: prj_ws12Su6Z5bCQCmIC7AVrT8rRhLnF, Team: Jay Layco's projects - team_K4IsiEAa1G2LBBRbqwgM4iiW)
  2. New Minimal Test Project (gemini-api-test): Created to isolate the issue with identical settings and simplified code.

    • vercel.json and api/gemini-chat.js configured as above for nodejs18.x.
    • package.json: {"dependencies": { "@google/generative-ai": "^0.14.1" }}
    • Vercel Dashboard Node.js Version (Build Environment): Set to 18.x.
    • Outcome: Same error, and local CLI logs again showed Vercel’s API responding with "config":{"version":1}.
    • Failed Deployment Inspect URL: https://vercel.com/jay-laycos-projects/gemini-api-test/8ywS9NVLuuEx12UhpweXZAoaJPMq?filter=errors
    • (Project ID: prj_2vGhatZNfW689tmCtEkbX8gvYL3F)

It seems like my projects are being forced into a V1 configuration context by Vercel’s backend, making valid V2 runtime definitions fail.

Has anyone encountered this behavior where version: 2 in vercel.json isn’t fully respected, leading to this runtime error? Any suggestions would be highly appreciated.

Thank you!

Hi @jayco01, welcome to the Vercel Community!

Sorry that you’re facing this issue.

I’d suggest removing the Node.js version declaration from all the places (including vercel.json) and then using the engines field in the package.json to set the Node version. For more information, see version override docs.

Also, using a new version of Node will be better because 18.x will reach end of life on Vercel on 1 August 2025. For more information, refer to Supported Node.js versions.

1 Like

Thank You! This fixed the issue.

1 Like

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