Quantcast
Channel: Active questions tagged aws-lambda - Stack Overflow
Viewing all articles
Browse latest Browse all 4012

When synth or deploy with AWS CDK getting bundling error related to knex

$
0
0

I am using only the mssql client. But I am getting below bundling errors when I try to run cdk synth.

  • Node.js - v18.16.0
  • CDK - 2.95.1
  • knex - 2.5.1
dirname /.../my-repo/cdk/my-app/lib/lambdaBundling asset api---app/get-last-sales-no/Code/Stage...✘ [ERROR] Could not resolve "sqlite3"    node_modules/knex/lib/dialects/sqlite3/index.js:42:19:      42 │     return require('sqlite3');╵                    ~~~~~~~~~  You can mark the path "sqlite3" as external to exclude it from the bundle, which will remove this  error. You can also surround this "require" call with a try/catch block to handle this failure at  run-time instead of bundle-time.✘ [ERROR] Could not resolve "pg"    node_modules/knex/lib/dialects/pgnative/index.js:13:19:      13 │     return require('pg').native;╵                    ~~~~  You can mark the path "pg" as external to exclude it from the bundle, which will remove this  error. You can also surround this "require" call with a try/catch block to handle this failure at  run-time instead of bundle-time.✘ [ERROR] Could not resolve "mysql2"    node_modules/knex/lib/dialects/mysql2/index.js:15:19:      15 │     return require('mysql2');╵                    ~~~~~~~~  You can mark the path "mysql2" as external to exclude it from the bundle, which will remove this  error. You can also surround this "require" call with a try/catch block to handle this failure at  run-time instead of bundle-time.✘ [ERROR] Could not resolve "pg"    node_modules/knex/lib/dialects/redshift/index.js:44:19:      44 │     return require('pg');╵                    ~~~~  You can mark the path "pg" as external to exclude it from the bundle, which will remove this  error. You can also surround this "require" call with a try/catch block to handle this failure at  run-time instead of bundle-time.

Did some research and found out that some got this fixed by marking knex itself or the client dependencies as external for esbuild. The thing is I am not using esbuild directly. AWS CDK should be using it under the hood I guess.

Anyway to fix this?


Viewing all articles
Browse latest Browse all 4012

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>