VOOZH about

URL: https://repost.aws/questions/QUZs72yAJTQYuHr-OCk8fbyg/error-when-trying-to-import-package-installed-using-lambda-layer-on-nodejs14-es-module-enabled-lambda-function

⇱ Error when trying to import package installed using lambda layer on nodejs14 ES module enabled lambda function | AWS re:Post


Skip to content

Error when trying to import package installed using lambda layer on nodejs14 ES module enabled lambda function

1

I have created a lambda function on the nodejs14 runtime that has the ES module enabled. I have installed a custom package using the lambda layer following the folder structure specified on documentation.

nodejs/node_modules/my-package-name/index.js

or

nodejs/node14/node_modules/my-package-name/index.js

When I try to import this package

import my-package-name from "my-package-name"

I get an error that says can't find the module. The weird part is it works perfectly fine when CommonJS is enabled (ES module disabled).

Language
English

asked 4 years ago1.1K views

1 Answer
  • Newest
  • Most votes
  • Most comments
Are these answers helpful? Upvote the correct answer to help the community benefit from your knowledge.
0

Not sure if you ever got an answer on this but we just went through the same issue with Node.js 16. I updated my original question with support's response. Short answer, not possible. Longer answer, you can use a wrapper to get the module paths.

answered 4 years ago