-
Notifications
You must be signed in to change notification settings - Fork 36
Description
I am trying to understand if it is possible to integrate datadog-lambda-js
into a Node lambda which is using ESM (modules).
I get errors like the following:
2025-06-20T12:06:48.139Z undefined ERROR Uncaught Exception {"errorType":"Error","errorMessage":"require() of ES Module /var/task/index.js from /var/task/node_modules/datadog-lambda-js/dist/runtime/user-function.js not supported.
Instead change the require of index.js in /var/task/node_modules/datadog-lambda-js/dist/runtime/user-function.js to a dynamic import() which is available in all CommonJS modules.","code":"ERR_REQUIRE_ESM","stack":["Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/index.js from /var/task/node_modules/datadog-lambda-js/dist/runtime/user-function.js not supported.","Instead change the require of index.js in /var/task/node_modules/datadog-lambda-js/dist/runtime/user-function.js to a dynamic import() which is available in all CommonJS modules."," at TracingChannel.traceSync (node:diagnostics_channel:322:14)"," at Hook.Module.require (/var/task/node_modules/dd-trace/packages/dd-trace/src/ritm.js:97:31)"," at _tryRequireSync (/var/task/node_modules/datadog-lambda-js/dist/runtime/user-function.js:248:12)"]}
I would like to know if you have a simple example written in ESM style which I can follow.
I am deploying using the package (not the Lambda layer).