Does Greengrass V2 support Javascript ES6?

0

I'm running greengrass in a docker container. I deployed my nodejs14.x lambda to greengrass successfully, however when it tries to run I get this error

2022-07-01T19:25:37.166Z [ERROR] (pool-2-thread-21) com.example.employee: Failed to import function handler employee.handler due to exception: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /greengrass/v2/packages/artifacts-unarchived/com.example.employee/1.0.12/lambda-artifact/employee.js. {serviceInstance=0, serviceName=com.example.employee, currentState=RUNNING} 2022-07-01T19:25:37.166Z [ERROR] (pool-2-thread-21) com.example.employee: require() of ES modules is not supported.. {serviceInstance=0, serviceName=com.example.employee, currentState=RUNNING}

I do not get this error while running the same lambda in the AWS cloud console. It only happens when running the lambda inside of greengrass.

Also I went into the greengrass container, and ran my script manually, it launched just fine.

Something tells me its whatever launches the lambda runtime inside of greengrass that's the issue.

meteora
질문됨 2년 전258회 조회
1개 답변
3
수락된 답변

Greengrass V2 Lambda does not support loading ES modules. You can write your code as a non-module and it will load fine. You may also choose to not use a lambda, this is what I would suggest that you do. Instead of using a Lambda, use a native component which will then let you do anything that you want.

https://docs.aws.amazon.com/greengrass/v2/developerguide/create-components.html

AWS
전문가
답변함 2년 전
  • Thank you so much for the answer. I'll check into native components!

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠