You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ts-node inside AWS Lambda cannot resolve dependencies in /opt/nodejs/node_modules #1430
Using ts-node I'm trying to use Typescript directly inside lambda function on AWS, to do this I'm using this sample code:
require('ts-node/register');console.log('Register!');const{ main }=require('./src/test.ts');exports.handler=asyncfunctionhandler(){console.log('Starting...');awaitmain();console.log('Done!');};
The problem is that in my lambda the node_modules directory is placed in a layer /opt/nodejs/node_modules
So what happens is that ts-node doesn't find libraries on the imported sources giving errors such:
src/test.ts(2,21): error TS2307: Cannot find module '@aws-sdk/client-s3' or its corresponding type declarations.
I'm trying to override the configuration of ts-node using this code, but still no luck.
Activity