Layers with ES in node18.x

0

Is it the case that we can't use layers with ES in node18.x?

I am getting the following error upon trying to convert to ES in node18.x when my lambda tries to use layer code:

Runtime.UserCodeSyntaxError: SyntaxError: The requested module '/opt/nodejs/index.js' does not provide an export named 'MyLayerCode'"

I found this response to a question about 14.x and 16.x

ACCEPTED ANSWER Unfortunately AWS support has confirmed we can't utilize layers with ES:

importing ESM modules from layers seems to not be supported when using a module type in Lambda. [...] this is a Node feature blocking us to import ES modules from a layer as "NODE_PATH" variable is not supported by the ESM loader in node

Disappointing that AWS is making headway on supporting ES, but it means we lose the functionality of layers. Support provided a wrapper workaround that we'll be trying. It corresponds with what we found here. Hopefully this saves someone else the headache we've gone through the last week.

질문됨 일 년 전240회 조회
2개 답변
0
profile picture
전문가
답변함 일 년 전
0

Hi,

I would recommend you to raise a GitHub issue with the AWS NodeJS team. They would be able to provide assistance over the error that you are receiving.

Have a great day ahead!

AWS
지원 엔지니어
답변함 일 년 전

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

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

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

관련 콘텐츠