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?