Astro Cloudflare Pages SyntaxError: Unexpected token 'with'

I got this error recently when cloudflare pages build my code
No description
13 Replies
Walshy
Walshy2mo ago
guessing astro are using import with attribute now? https://github.com/tc39/proposal-import-attributes not sure your node version but i'd try updating it
James
James2mo ago
Detected the following tools from environment: pnpm@8.7.1, nodejs@18.17.1
Walshy
Walshy2mo ago
eh 18 should be fine using with afaik? but may be worth trying 20 - not fully sure what node vers support it (and what versions of it)
Walshy
Walshy2mo ago
ah yes 18.17 is too old
James
James2mo ago
done fixing it with v21.7.1
Walshy
Walshy2mo ago
it's still expecting import json from './file.json' assert { type: 'json' } instead of import json from './file.json' with { type: 'json' }
James
James2mo ago
Just set the ENV variable NODE_VERSION 21.7.1 and rebuild and it is successfully build
Walshy
Walshy2mo ago
https://nodejs.org/api/esm.html#import-attributes for ref perfect! interesting to see astro using import attributes already
James
James2mo ago
thx for the help @Walshy | Deploying yup
Marius B.
Marius B.2mo ago
@James are you using the experimental astro:env feature? And does your project work after deployment? In my case it throughs an error 500.
James
James2mo ago
My project works fine after this No I don’t use any env feature Just put the env through cloudflare dashboard Working perfectly fine after using latest nodejs version
Chinoman10
Chinoman102mo ago
FYI I added NODE_VERSION = 20 to Wrangler and it still failed. But when I did 21 it continued and only failed later when it said my worker is bigger than 1MiB in size 😅
Want results from more Discord servers?
Add your server