Astro Cloudflare Pages SyntaxError: Unexpected token 'with'

I got this error recently when cloudflare pages build my code
No description
13 Replies
Walshy
Walshy4mo 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
JamesOP4mo ago
Detected the following tools from environment: [email protected], [email protected]
Walshy
Walshy4mo 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
Walshy4mo ago
ah yes 18.17 is too old
James
JamesOP4mo ago
done fixing it with v21.7.1
Walshy
Walshy4mo ago
it's still expecting import json from './file.json' assert { type: 'json' } instead of import json from './file.json' with { type: 'json' }
James
JamesOP4mo ago
Just set the ENV variable NODE_VERSION 21.7.1 and rebuild and it is successfully build
Walshy
Walshy4mo ago
https://nodejs.org/api/esm.html#import-attributes for ref perfect! interesting to see astro using import attributes already
James
JamesOP4mo ago
thx for the help @Walshy | Deploying yup
Marius B.
Marius B.4mo 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
JamesOP4mo 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
Chinoman104mo 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