kit icon indicating copy to clipboard operation
kit copied to clipboard

Cloudflare: Unsupported Engine Error in @eslint/config-array with Node v18.17.1 and npm v9.6.7

Open fmaclen opened this issue 1 year ago • 12 comments
trafficstars

Describe the bug

I'm having issues deploying a SvelteKit app using @sveltejs/adapter-cloudflare with Typescript and ESLint. When trying to deploy the site I get this error:

19:55:54.108	Detected the following tools from environment: [email protected], [email protected]
19:55:54.108	Installing project dependencies: npm clean-install --progress=false
19:55:55.375	npm ERR! code EBADENGINE
19:55:55.376	npm ERR! engine Unsupported engine
19:55:55.377	npm ERR! engine Not compatible with your version of node/npm: @eslint/[email protected]
19:55:55.377	npm ERR! notsup Not compatible with your version of node/npm: @eslint/[email protected]
19:55:55.377	npm ERR! notsup Required: {"node":"^18.18.0 || ^20.9.0 || >=21.1.0"}
19:55:55.377	npm ERR! notsup Actual:   {"npm":"9.6.7","node":"v18.17.1"}

Reproduction

Reproduction: https://github.com/fmaclen/cloudflare-adapter-dependencies

Here are the settings I chose to generate the repository:

npm create svelte@latest cloudflare-adapter-dependencies  

create-svelte version 6.3.3

┌  Welcome to SvelteKit!
│
◇  Which Svelte app template?
│  Skeleton project
│
◇  Add type checking with TypeScript?
│  Yes, using TypeScript syntax
│
◇  Select additional options (use arrow keys/space bar)
│  Add ESLint for code linting
│
└  Your project is ready!

Logs

No response

System Info

System:
    OS: macOS 14.5
    CPU: (16) arm64 Apple M3
    Memory: 14.90 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - /usr/local/bin/node
    npm: 10.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 124.0.6367.208
    Safari: 17.5
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.2.2 
    @sveltejs/adapter-cloudflare: ^4.6.1 => 4.6.1 
    @sveltejs/kit: ^2.0.0 => 2.5.18 
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.1.1 
    svelte: ^4.2.7 => 4.2.18 
    vite: ^5.0.3 => 5.3.3

Severity

blocking all usage of SvelteKit

Additional Information

The site is not deployable with the current library versions set by npm create svelte@latest command.

fmaclen avatar Jul 12 '24 00:07 fmaclen

You’ll have to change the build node version to 18.8 or higher since cloudflare’s default is lower. You can read how in the link below https://developers.cloudflare.com/pages/configuration/language-support-and-tools/#supported-languages-and-tools

teemingc avatar Jul 12 '24 01:07 teemingc

@eltigerchino ah, thanks for the clarification! I ended up creating a .node-version file with: 18.18.0 and that fixed the deployment issue.

fmaclen avatar Jul 12 '24 01:07 fmaclen

I'm wondering if we should specify the node version for builds in .npmrc or the engines field in package.json (which doesn't work for cloudflare pages). This could become an issue with other platforms too.

teemingc avatar Jul 12 '24 01:07 teemingc

I was going to file another issue but I'm running into a similar situation with @sveltejs/enhanced-img (0.3.0) where I need to manually set these optional dependencies for the Cloudflare build to suceed:

"optionalDependencies": {
	"@rollup/rollup-linux-x64-gnu": "^4.0.0",
	"@cloudflare/workerd-linux-64": "1.20240701.0"
},

I'm guessing this is because the package-lock.json was generated on an arm-based system and Cloudflare runs on x68.

fmaclen avatar Jul 12 '24 01:07 fmaclen

I'm wondering if we should specify the node version for builds in .npmrc or the engines field in package.json (which doesn't work for cloudflare pages). This could become an issue with other platforms too.

Our engines field requires 18.13: https://github.com/sveltejs/kit/blob/144fb75c8280695d8aeb3228904bebb262e171a7/packages/kit/package.json#L105

It seems the issue is that the project is using eslint, which requires a higher version. I'm not sure there's anything we can or should do about this on our side. Maybe we could have the wizard also ask you to setup an adapter and if you choose both cloudflare and eslint then we can create an .npmrc for you

The best thing might be for Cloudflare to start using a newer version of Node by default. I imagine this will be hitting lots of users whether or not they're using SvelteKit since eslint is so popular. FYI @dario-piotrowicz

benmccann avatar Jul 12 '24 03:07 benmccann

Maybe we could have the wizard also ask you to setup an adapter and if you choose both cloudflare and eslint then we can create an .npmrc for you

@benmccann could you add an .npmrc to always just use a higher node version when the cloudflare adapter is used? is there any case in which you would prefer to stay on 18?

The best thing might be for Cloudflare to start using a newer version of Node by default.

yes... I totally get that... but we can't really just bump the version in the build image as it would potentially break users (e.g. someone could be able to deploy the same exact project today but not tomorrow)

this is something that the team is very against with as it would make for a poor/unstable DX

the only way to address this is to have a new v3 build image and set that as the default for newer projects (exactly as we did for v2). Unfortunately we don't want to do that too often either as it requires a bunch of extra maintenance burden on our side (+ the extra UI clatter for users I guess)

we'll definitely do that at some point! but I don't think that's going to happen soon 😓 (@walshydev do you know if there are any plans for a v3?)

dario-piotrowicz avatar Jul 12 '24 12:07 dario-piotrowicz

@benmccann could you add an .npmrc to always just use a higher node version when the cloudflare adapter is used? is there any case in which you would prefer to stay on 18?

That would be the easiest solution, but users setup the adapter, so they'd be responsible for doing it. I think the most we can do is document that it's recommended to do so.

benmccann avatar Jul 12 '24 12:07 benmccann

@benmccann could you add an .npmrc to always just use a higher node version when the cloudflare adapter is used? is there any case in which you would prefer to stay on 18?

That would be the easiest solution, but users setup the adapter, so they'd be responsible for doing it. I think the most we can do is document that it's recommended to do so.

It's worth noting that adapter-auto also wouldn't be as seamless in this case

teemingc avatar Jul 12 '24 15:07 teemingc

@WalshyDev do you know if there are any plans for a v3?

Not aware of any near-term plans.

WalshyDev avatar Jul 12 '24 18:07 WalshyDev

I just ran into this and setting the .node-version file to 18.18.0 and the Cloudflare NODE_VERSION env var to 18 did not solve the issue. As an alternate solution, if you're not specifically dependent on eslint for some reason, completely removing eslint and adding oxlint https://oxc.rs/docs/guide/usage/linter to an adapter-cloudflare project deploys to Cloudflare without issue using either Node 18 or Node 20.

fredguest avatar Jul 20 '24 15:07 fredguest

You don't need to set the ENV variable, you can just set the .node-version file to ^18.18.0. One or the other.

J

jdgamble555 avatar Jul 21 '24 18:07 jdgamble555

You don't need to set the ENV variable, you can just set the .node-version file to ^18.18.0. One or the other.

J

Thanks!

izakdvlpr avatar Oct 10 '24 18:10 izakdvlpr