node.jsmongoosedeploymentbackendrender

Error with Mongoose and Node.js versions when deploying on Render


I'm encountering an issue while trying to deploy my backend application on Render. I have updated Node.js to version 20.9.0 and also upgraded Mongoose to version 8.0.0. However, I'm getting the following error:

error [email protected]: The engine "node" is incompatible with this module.
Expected version ">=16.20.1". Got "14.17.0"

It seems that Mongoose is expecting a Node.js version of at least 16.20.1, but it's detecting my Node.js version as 14.17.0. I've confirmed that I'm using Node.js 20.9.0 locally, so I'm not sure why Render is detecting the older version.

How can I resolve this version compatibility issue and successfully deploy my backend on Render?


Solution

  • have your tried locking the Node engine on your package.json?

    check this docs: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#engines

    You need to add something like this on package.json file.

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