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.
Thank you so much for the answer. I'll check into native components!
It's now 2 years later. Is this still true for GG v2 lambda functions? We have a bunch of lambdas that we use in a GG environment. We're not at the point where we can factor them into native components yet.
A person on the team created a node package as an ES6 module. One of the lambdas is now dependent on this package so we updated the lambda to be an ES6 module. Everything looked fine until we tried to run it on the GG device. Seems like I'm running into the same thing here so I wanted to ask and make sure ES6 modules are still not supported in GGv2.