serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

Module parse failed: Unexpected token

Open mtin79 opened this issue 2 years ago • 2 comments

Hi out there, currently working on an project where i run into the following error which doesn't appear when i run the next server locally. Only when i deploy it to aws (via npm run serverless --stage production) i get the following error:

Failed to compile.

./node_modules/@aws-sdk/client-dynamodb/dist-cjs/runtimeConfig.js 32:34
Module parse failed: Unexpected token (32:34)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|         runtime: "node",
|         defaultsMode,
>         bodyLengthChecker: config?.bodyLengthChecker ?? util_body_length_node_1.calculateBodyLength,
|         credentialDefaultProvider: config?.credentialDefaultProvider ?? (0, client_sts_1.decorateDefaultCredentialProvider)(credential_provider_node_1.defaultProvider),
|         defaultUserAgentProvider: config?.defaultUserAgentProvider ??


> Build error occurred
Error: > Build failed because of webpack errors

Any ideas or hints are much appreciated!

mtin79 avatar Jan 30 '23 13:01 mtin79

what nodejs runtime version are you using?

ykurniawan avatar Feb 08 '23 14:02 ykurniawan

Hi @ykurniawan , locally i am using node 14.20.1 via .nvmrc and package-lock.json is mentioning also node >= 14....

Screenshot 2023-02-10 at 11 07 32

mtin79 avatar Feb 10 '23 10:02 mtin79