Hi everyone, I have the following config for creat...
# help
l
Hi everyone, I have the following config for creating API's and it works locally
Copy code
defaults: {
      function: {
        environment,
        vpc: vpc,
        vpcSubnets: {
          subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
        },
        bundle: {
          externalModules: ['pg', 'better-sqlite3', 'mysql2']
        }
      }
    },
But the above does not work when I try to deploy with seed.run
Copy code
Error: There was a problem transpiling the Lambda handler: > node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:80:68: error: Could not resolve "pg" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
    80 │ ... const pgModule = await Promise.resolve().then(() => require('pg'));
       ╵                                                                 ~~~~
 > node_modules/kysely/dist/cjs/dialect/sqlite/sqlite-driver.js:68:72: error: Could not resolve "better-sqlite3" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
    68 │ ...ule = await Promise.resolve().then(() => require('better-sqlite3'));
       ╵                                                     ~~~~~~~~~~~~~~~~
 > node_modules/kysely/dist/cjs/dialect/mysql/mysql-driver.js:99:71: error: Could not resolve "mysql2" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
    99 │ ...mysqlModule = await Promise.resolve().then(() => require('mysql2'));
Please let me know if there is anything else that I need to add to the config. Thanks cc: @thdxr @Frank
f
Hey @lgupta, is it the same issue as what you saw locally? https://serverless-stack.slack.com/archives/C01JG3B20RY/p1651953843630849
l
Hi @Frank yes but local is working after adding externalModules key. I am currently able to get build also working after installing pg, mysql2 and better-sqlite3 modules. I am not sure if that is a good solution though. Thanks
f
I see. If you try deploying from ur local machine, does it work?
l
No I see the same errors.
t
@lgupta is there any way you could send me your repo?