Render doesn't respect "engines" setting in `package.json` as the docs suggest

I’m trying to configure Render to use a more modern node.js version following the docs here. I have a project containing a node.js project in the next/ subdirectory with a package.json file including:

  "engines": {
    "node": ">=16"
  },

However, when I push my changes the build fails:

Nov 18 05:27:12 PM  ==> Cloning from https://github.com/cuddlefish-app/cuddlefish...
Nov 18 05:27:13 PM  ==> Checking out commit 7f5909209bef3a4dfacecaf4c3fd4aa9378abd8c in branch main
Nov 18 05:27:27 PM  ==> Downloading cache...
Nov 18 05:27:45 PM  ==> Downloaded 646MB in 6s. Extraction took 11s.
Nov 18 05:27:48 PM  ==> Running build command 'cd next/ && yarn install --frozen-lockfile && yarn run build'...
Nov 18 05:27:48 PM  yarn install v1.22.5
Nov 18 05:27:48 PM  [1/5] Validating package.json...
Nov 18 05:27:48 PM  error next@: The engine "node" is incompatible with this module. Expected version ">=16". Got "14.17.0"
Nov 18 05:27:48 PM  error Found incompatible module.
Nov 18 05:27:48 PM  info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Nov 18 05:27:48 PM  ==> Build failed 😞

How can I set the node.js version in package.json as the docs suggest?

Just tried the .node-version file route, and that doesn’t work either.

Where did you place the .node-version file? Could you maybe try with the .node-version in the root directory and not in /next. The detection is done before the build command - I tried this on a test project and with package.json in the root and on changing the engines my output was:

Nov 19 02:07:30 PM  ==> Downloading cache...
Nov 19 02:07:37 PM  ==> Downloaded 129MB in 3s. Extraction took 3s.
Nov 19 02:07:38 PM  ==> Detected Node version 17.1.0
Nov 19 02:07:40 PM  ==> Running build command 'yarn; yarn build'...

I’m in a monorepo setup so I don’t want my .node-version/package.json file to apply to every project within the repo. This would certainly explain why it doesn’t work though!

We have work planned around our Monorepo support - https://feedback.render.com/features/p/monorepo-support is what to keep an eye on,

John B

Same problem here. .node-version in the root seem to work, but both "engines": {"node": "16"} or NODE_VERSION=16 don’t seem to.

Setting temporarily the NODE_VERSION env variable (as per render docs), deploying the service and then removing it works.

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