Netlify error when deployin sveltekit app

Viewed 421

when i build my sveltekit app locally and then run yarn preview, everything works as it should, but when i deploy my site to Netlify i get this error

{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Unexpected token '.'",
"trace": [
"Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '.'",
"    at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
"    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
"    at Object.<anonymous> (/var/runtime/index.js:43:30)",
"    at Module._compile (internal/modules/cjs/loader.js:999:30)",
"    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
"    at Module.load (internal/modules/cjs/loader.js:863:32)",
"    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
"    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
"    at internal/main/run_main_module.js:17:47"
]
}

I am using the netlify adapter, and the project uses firebase.

2 Answers

I had the same problem recently and fixed it the following way:

Go to your Netlify account and select the site you want to build. Switch to “Site settings” > “Build & deploy” > “Environment variables”. With “Edit variables” add the following:

Key: AWS_LAMBDA_JS_RUNTIME
Value: nodejs14.x

Netlify deployment settings; environment variables: Key: AWS_LAMBDA_JS_RUNTIME, Value: nodejs14.x

Save and try deploying your site again. :)


credits: benmccann; netlify docs

The answer from Mue worked for me only after adding the following in my netlify.toml file (taken from the adapter-netlify README):

[functions]
  directory = "functions"
  node_bundler = "esbuild"
Related