serverless-esbuild icon indicating copy to clipboard operation
serverless-esbuild copied to clipboard

nodejs18.x with arm64 issue

Open reikje opened this issue 2 years ago • 5 comments

Describe the bug I am using the serverless framework successfully using nodejs16.x and arm64. When I bump to nodejs18.x and no further changes, I end up getting: Runtime.ImportModuleError: Error: Cannot find module 'handler' when executing the Lambda function - indicating some sort of transpile/build error.

I have not changed any esbuild related dependencies:

    "esbuild": "^0.15.7",
    "esbuild-node-externals": "^1.5.0",
    "serverless-esbuild": "^1.32.8",

Getting warnings in npm from esbuild-node-externals trying to use the latest esbuild version.

Which versions should I use to successfully build and deploy node18 / arm?

To Reproduce Try to set up a project that targets nodejs18.x and arm64 with serverless-esbuild and deploys a simple Hello World lambda function.

Expected behavior "Hello World" is returned when running curl against the deployed Lambda.

Versions (please complete the following information):

  "dependencies": {
    "@aws-sdk/client-s3": "^3.272.0",
    "aws-jwt-verify": "^3.4.0"
  },
  "devDependencies": {
    "@aws-sdk/client-dynamodb": "^3.272.0",
    "@serverless/typescript": "^3.27.0",
    "@types/aws-lambda": "^8.10.110",
    "@types/jest": "^29.4.0",
    "@types/node": "^18.14.0",
    "@typescript-eslint/eslint-plugin": "^5.36.1",
    "@typescript-eslint/parser": "^5.36.1",
    "aws-sdk-client-mock": "^2.0.1",
    "esbuild": "^0.15.7",
    "esbuild-node-externals": "^1.5.0",
    "eslint": "8.34.0",
    "jest": "^29.4.3",
    "jest-extended": "^3.2.4",
    "json-schema-to-ts": "^2.5.5",
    "prettier": "^2.8.4",
    "serverless": "^3.27.0",
    "serverless-api-gateway-caching": "^1.9.0",
    "serverless-esbuild": "^1.32.8",
    "ts-jest": "^29.0.5",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.1.0",
    "typescript": "^4.9.5"
  },

reikje avatar Feb 20 '23 08:02 reikje

Did you solve this already? @reikje

miguel-sobong avatar May 02 '23 11:05 miguel-sobong

Same issue here.

markadv avatar May 18 '23 09:05 markadv

I am having a similar issue, I noticed that the generated .js file that invokes the function file is referring to an index.js file, and the function file is still a .ts file. There doesn't seem to be any transpilation from the source .ts file into a .js file. Downgrading to platform node14 fixed the problem for me, but I need node16x min for the main dependency I am using inside the lambda.

rodrigomf24 avatar May 19 '23 08:05 rodrigomf24

I found a fix, make sure you are using the latest version of serverless-esbuild, I bumped mine to 1.44.0 and it fixed the problem. I also want to clarify I have my platform configured to node16x and the esbuild config target to node16

rodrigomf24 avatar May 19 '23 08:05 rodrigomf24

Hmm... the OP already said that this works on node16x and the issue was updating to node18x.

markadv avatar May 22 '23 07:05 markadv