cloudflare / pages-build-image

Apache License 2.0
44 stars 1 forks source link

Default NodeJS version 18.17.1 breaks default SvelteKit app build in Cloudflare Pages. #9

Open onnimonni opened 4 months ago

onnimonni commented 4 months ago

Hey!

I used the default create sveltekit command and created a git repository and pushed it to github

$ npm create cloudflare@latest my-svelte-app -- --framework=svelte
$ cd my-svelte-app
$ gh repo create my-svelte-app --private --source=. --remote=origin
$ git push origin HEAD
$ cat package.json | grep typescript-eslint
    "@typescript-eslint/eslint-plugin": "^7.0.0",
    "@typescript-eslint/parser": "^7.0.0",

After this I visited https://dash.cloudflare.com/MY-ACCOUNT-ID-HERE/pages/new/provider/github and deployed the app.

The default version for the typescript-eslint/parser is 7.6.0 as of now and default NodeJS version seems to 18.17.1 according to this documentation page.

Because of this the svelte kit app can't be deployed to Cloudflare pages and results in this error:

17:39:38.540 | Successfully read wrangler.toml configuration file
-- | --
17:39:38.696 | Detected the following tools from environment: npm@9.6.7, pnpm@8.7.1, nodejs@18.17.1
17:39:39.499 | Installing project dependencies: pnpm install
17:39:40.187 | Lockfile is up to date, resolution step is skipped
17:39:40.214 | ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)
17:39:40.215 | Β 
17:39:40.215 | Your Node version is incompatible with "/@typescript-eslint/eslint-plugin/7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.4.5)".
17:39:40.215 | Β 
17:39:40.215 | Expected version: ^18.18.0 \|\| >=20.0.0
17:39:40.215 | Got: v18.17.1

I was able to fix this by overriding the NodeJS version in .node-version

$ echo 21.7.2 > .node-version
$ git add .node-version
$ git commit -m "Force newer NodeJS"
$ git push origin HEAD

I recommend pushing the default version to higher so that others won't run into the same issue πŸ™‡.

See also the log from create Cloudflare cli here:

using create-cloudflare version 2.18.1

β•­ Create an application with Cloudflare Step 1 of 3
β”‚
β”œ In which directory do you want to create your application?
β”‚ dir ./my-svelte-app
β”‚
β”œ What type of application do you want to create?
β”‚ type Website or web app
β”‚
β”œ Which development framework do you want to use?
β”‚ framework Svelte
β”‚
β”œβ€ŠContinue with Svelte via `npx create-svelte@6.0.10 my-svelte-app`
β”‚

create-svelte version 6.0.10

β”Œ  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, Add Prettier for code formatting, Add Playwright for browser testing, Add Vitest for unit testing
β”‚
β””  Your project is ready!

βœ” Typescript
  Inside Svelte components, use <script lang="ts">

βœ” ESLint
  https://github.com/sveltejs/eslint-plugin-svelte

βœ” Prettier
  https://prettier.io/docs/en/options.html
  https://github.com/sveltejs/prettier-plugin-svelte#options

βœ” Playwright
  https://playwright.dev

βœ” Vitest
  https://vitest.dev

Install community-maintained integrations:
  https://github.com/svelte-add/svelte-add

Next steps:
  1: cd my-svelte-app
  2: npm install
  3: git init && git add -A && git commit -m "Initial commit" (optional)
  4: npm run dev -- --open

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://svelte.dev/chat

β”œ Copying template files
β”‚ files copied to project directory
β”‚
β”œ Installing dependencies
β”‚ installed via `npm install`
β”‚
β•° Application created

β•­ Configuring your application for Cloudflare Step 2 of 3
β”‚
β”œ Installing wrangler A command line tool for building Cloudflare Workers
β”‚ installed via `npm install wrangler --save-dev`
β”‚
β”œ Installing @cloudflare/workers-types
β”‚ installed via npm
β”‚
β”œ Adding latest types to `tsconfig.json`
β”‚ added @cloudflare/workers-types/2023-07-01
β”‚
β”œ Retrieving current workerd compatibility date
β”‚ compatibility date 2024-04-05
β”‚
β”œ Adding the Cloudflare Pages adapter
β”‚ installed @sveltejs/adapter-cloudflare
β”‚
β”œβ€ŠChanging adapter in svelte.config.js
β”‚
β”œβ€ŠUpdating global type definitions in app.d.ts
β”‚
β”œ Adding Wrangler files to the .gitignore file
β”‚ updated .gitignore file
β”‚
β”œ Updating `package.json` scripts
β”‚ updated `package.json`
β”‚
β”œ Do you want to use git for version control?
β”‚ yes git
β”‚
β”œ Initializing git repo
β”‚ initialized git
β”‚
β”œ Committing new files
β”‚ git commit
β”‚
β•° Application configured

β•­ Deploy with Cloudflare Step 3 of 3
β”‚
β”œ Do you want to deploy your application?
β”‚ no deploy via `npm run deploy`
β”‚
β”œ  APPLICATION CREATED  Deploy your application with npm run deploy
β”‚
β”‚ Navigate to the new directory cd my-svelte-app
β”‚ Run the development server npm run dev
β”‚ Preview your application npm run preview
β”‚ Deploy your application npm run deploy
β”‚ Read the documentation https://developers.cloudflare.com/pages
β”‚ Stuck? Join us at https://discord.gg/cloudflaredev
β”‚
β•° See you again soon!