Unable to deploy Svelte due to mismatch of Node version

Hello, I’m currently rewriting one of my sites using svelte, I’m building a dev branch to see if everything works as expected, I’ve followed the guide you have for SvelteKit, but when it tries to build I’m getting the following error:

9:24:40 AM: Installing npm packages using npm version 6.13.4
9:24:42 AM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code ENOTSUP
9:24:42 AM: npm ERR! notsup Unsupported engine for @sveltejs/kit@1.0.0-next.589: wanted: {"node":">=16.14"} (current: {"node":"8.17.0","npm":"6.13.4"})
9:24:42 AM: npm ERR! notsup Not compatible with your version of node/npm: @sveltejs/kit@1.0.0-next.589
9:24:42 AM: npm ERR! notsup Not compatible with your version of node/npm: @sveltejs/kit@1.0.0-next.589
9:24:42 AM: npm ERR! notsup Required: {"node":">=16.14"}
9:24:42 AM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
9:24:42 AM: npm ERR! notsup Actual:   {"npm":"6.13.4","node":"8.17.0"}
9:24:42 AM: npm ERR! A complete log of this run can be found in:
9:24:42 AM: npm ERR!     /opt/buildhome/.npm/_logs/2023-05-19T07_24_42_690Z-debug.log
9:24:42 AM: Error during npm install
9:24:42 AM: Build was terminated: dependency_installation script returned non-zero exit code: 1
9:24:42 AM: Failing build: Failed to install dependencies

I’m thinking of downgrading my local dev env to use node 8 and see if that would make things work out, but I also wonder if there’s the ability to use a more recent version of Node within the deployment box

thanks,
Mat.

It seems somewhere in the repository something is set to tell the build system to use a very old Node.js version. This is possibly in an .nvmrc file, or NODE_VERSION environment variable. You’ll need to track this down and remove it.

in the current branch there’s none, is it possible this is picked up from the main branch instead (which is currently out of date, since it’s using lts/carbon)?

Netlify will only read the branch you selected to deploy from. Did you select the correct branch, or leave it as the main branch?

no, I don’t want to re-deploy the main branch, I’m doing the rewrite on a separate branch. I’ve added the branch in the “branch deploys” configuration. Now when it’s trying to build for that branch it’s failing with the aforementioned error.

(and yes, I’ve selected the right branch - at least I see it when I’m pushing I’m seeing the build being triggered against it)

As @jasiqli said, something in your build is stuck with v8.17. Here’s a couple of things you could try:

  1. Clear cache and redeploy
  2. Check environment variables in any netlify .toml config files / netlify dashboard
  3. Check there isn’t a rogue .nvmrc in your repo with an outdated version

Additionally, I’d probably recommend adding a .nvmrc with 18 just to be on the safe side.

thanks @kylesloper and @jasiqli : unfortunately none of the 3 points raised solved my problem. It does seem like the deployment had the main branch node version stuck with it (or falling back to it, while it shouldn’t have according to @jasiqli ), point in fact that as soon as I added the .nvmrc file with v18 inside, it deployed without hiccups!

Thanks for the support. Wondering if this is just a one-off problem, or something that needs further investigation.

1 Like