Michael James Munar
03/02/2022, 10:48 AMnpx sst start
^ when I run this, everything works fine, but on deployment I keep getting this error which I couldn't find how to fix
Error: There was a problem transpiling the Lambda handler: > node_modules/pg/lib/native/client.js:4:21: error: Could not resolve "pg-native" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
4 │ var Native = require('pg-native')
╵ ~~~~~~~~~~~
at Object.bundle (/tmp/seed/source/node_modules/@serverless-stack/core/dist/runtime/handler/node.js:226:23)
at Object.bundle (/tmp/seed/source/node_modules/@serverless-stack/core/dist/runtime/handler/handler.js:19:16)
at new Function (/tmp/seed/source/node_modules/@serverless-stack/resources/src/Function.ts:362:39)
at Function.fromDefinition (/tmp/seed/source/node_modules/@serverless-stack/resources/src/Function.ts:514:14)
at Api.createFunctionIntegration (/tmp/seed/source/node_modules/@serverless-stack/resources/src/Api.ts:579:23)
at Api.addRoute (/tmp/seed/source/node_modules/@serverless-stack/resources/src/Api.ts:466:26)
at /tmp/seed/source/node_modules/@serverless-stack/resources/src/Api.ts:303:12
at Array.forEach (<anonymous>)
at Api.addRoutes (/tmp/seed/source/node_modules/@serverless-stack/resources/src/Api.ts:302:25)
at new Api (/tmp/seed/source/node_modules/@serverless-stack/resources/src/Api.ts:272:10)
There was an error synthesizing your app.
Anybody knowledgeable on bundling, please enlighten me
Edit: the package I added is pg-promise
-> https://github.com/vitaly-t/pg-promiseRoss Coundon
03/02/2022, 10:50 AMbundle.nodeModules = ['pg-promise']
to force the install of this rather than having it bundledMichael James Munar
03/02/2022, 11:03 AMRoss Coundon
03/02/2022, 11:13 AMexport default function main(app: <http://sst.App|sst.App>): void {
app.setDefaultFunctionProps({
bundle: {
nodeModules: ['pg-promise'],
},
});
new YourStack(app, 'your-stack');
}
We do it like that in the index.tsMichael James Munar
03/02/2022, 11:30 AMRoss Coundon
03/02/2022, 11:38 AMFrank
Could not resolve "xxxx"
, and then suggest a fix? Better ideas?Jay
Ross Coundon
03/03/2022, 12:18 PMFrank