jamlen
04/27/2022, 8:57 AM1.0.0-beta.23
and I’m getting this error… although I’m not 100% sure this is an upgrade issue, I’m still in the very early, walking skeleton phase of dev so lots of things are changing…
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 (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/core/dist/runtime/handler/node.js:184:23)
at Object.bundle (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/core/dist/runtime/handler/handler.js:19:16)
at new Function (/Users/jamlen/dev/src/github.com/sst-demosst-demo/node_modules/@serverless-stack/resources/src/Function.ts:725:39)
at RDS.createMigrationsFunction (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/resources/src/RDS.ts:371:16)
at new RDS (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/resources/src/RDS.ts:187:36)
at new CustomerProfileStack (/Users/jamlen/dev/src/github.com/sst-demo/src/platforms/customerProfile/index.ts:16:25)
at Object.main (/Users/jamlen/dev/src/github.com/sst-demo/stacks/index.ts:23:5)
at Object.<anonymous> (/Users/jamlen/dev/src/github.com/sst-demo/.build/run.js:92:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Scott
04/27/2022, 9:30 AMjamlen
04/27/2022, 9:45 AMtypeorm
but that is using v0.67 (I think) and I didn’t have to define that in there.jamlen
04/27/2022, 9:46 AMjamlen
04/27/2022, 9:46 AMjamlen
04/27/2022, 9:51 AM.
├── README.md
├── cdk.context.json
├── lerna.json
├── package.json
├── src
│ ├── packages
│ │ └── clients
│ │ ├── notificationConsumer.ts
│ │ ├── index.ts
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── test
│ │ └── tsconfig.json
│ └── platforms
│ ├── customerProfile
│ │ ├── data
│ │ │ ├── index.ts
│ │ │ └── migration
│ │ ├── entities
│ │ │ ├── Customer.ts
│ │ │ └── index.ts
│ │ ├── index.ts
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── scripts
│ │ ├── services
│ │ │ ├── api
│ │ │ │ └── customer.ts
│ │ │ └── events
│ │ │ └── userCreated.ts
│ │ ├── test
│ │ └── tsconfig.json
│ ├── fulfilment
│ ├── order
│ └── user
│ ├── index.ts
│ ├── jest.config.js
│ ├── package.json
│ ├── scripts
│ ├── services
│ │ ├── auth
│ │ │ └── cognitoTriggers.ts
│ │ └── events
│ ├── test
│ └── tsconfig.json
├── sst.json
├── stacks
│ └── index.ts
├── tsconfig.json
└── yarn.lock
jamlen
04/27/2022, 9:52 AMScott
04/27/2022, 10:18 AMjamlen
04/27/2022, 10:21 AMScott
04/27/2022, 10:23 AMjamlen
04/27/2022, 10:35 AMjamlen
04/27/2022, 10:57 AMFrank
'GET /public': {
function: {
handler: "...",
bundle: {
nodeModules: ['pg-native']
}
}
}
},
jamlen
04/28/2022, 8:14 AMthis.api = new sst.Api(this, "CustomerApi", {
defaults: {
function: {
bundle: { nodeModules: ['typeorm', 'pg', 'pg-native'] },
srcPath: `${props.srcPath}/customerProfile`,
environment: {
DATABASE: 'customerProfile',
CLUSTER_ARN: cluster.clusterArn,
SECRET_ARN: cluster.secretArn,
},
permissions: [cluster, props.bus],
},
authorizer: "iam",
},
routes: {
"GET /customer": `services/api/customer.get`,
"POST /customer": `services/api/customer.post`,
"GET /customer/{id}": `services/api/customer.findOne`,
"PUT /customer/{id}": `services/api/customer.put`,
"PATCH /customer/{id}": `services/api/customer.patch`,
"DELETE /customer/{id}": `services/api/customer.remove`,
}
})
Scott
04/28/2022, 9:20 AMthis.api = new Api(this, 'Api', {
defaultAuthorizationType: ApiAuthorizationType.AWS_IAM,
defaultFunctionProps: {
environment: {
// PRODUCTS_BUCKET: productsBucket.bucketName,
// LISTINGS_BUCKET: listingsBucket.bucketName,
DATABASE: DATABASE,
CLUSTER_ARN: database.clusterArn,
SECRET_ARN: database.secretArn,
},
permissions: [database],
// bundle: {
// nodeModules: ['typeorm'],
// },
},
routes: {
'GET /run/migrations': {
function: {
handler: 'src/run/migrations.main',
bundle: {
nodeModules: ['pg-native'],
},
},
authorizationType: ApiAuthorizationType.NONE,
},
},
});
jamlen
04/28/2022, 9:24 AMScott
04/28/2022, 10:19 AMFrank
Frank
sst build
, and go into .build/cdk.out
, you should see a bunch of asset.*
directories.Frank
node_modules
folders in them?jamlen
04/28/2022, 2:44 PMyarn sst build
I only get one asset.*
directory and it is for the stack with the auth (and trigger function).jamlen
04/28/2022, 2:45 PMnode_modules
jamlen
04/28/2022, 2:46 PMuuid
as an example) then in there I do get a node_modules
folder… still fails with the same error for pg-native
though.jamlen
04/28/2022, 2:46 PMUsing stage: jamlen
Preparing your SST app
Synthesizing CDK
Building function services/auth/cognitoTriggers.postAuth
Building function index.handler
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')
jamlen
04/28/2022, 2:47 PMindex.handler
from… I was expecting it to say building function services/api/customer.get
Frank
sst build
again and send me the .build/sst-debug.log
?jamlen
04/28/2022, 4:57 PMnode_modules
at the top level does have the package, so I don’t think its having issues installing the packageFrank
pg-native
in ur package.json?Scott
04/29/2022, 7:10 AMjamlen
04/29/2022, 7:53 AMpg-native
in package.json… I think it will be a peer dependency for pg
which is in my package.json. If I try to yarn add pg-native
I get this:
error /Users/jamlen/dev/src/github.com/sst-demo/node_modules/libpq: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/jamlen/dev/src/github.com/sst-demo/node_modules/libpq
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@14.19.0 | darwin | x64
gyp info find Python using Python version 3.9.7 found at "/usr/local/opt/python@3.9/bin/python3.9"
gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args '/Users/jamlen/dev/src/github.cosst-demo/node_modules/@npmcli/run-script/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/jamlen/dev/src/github.com/sst-demo/node_modules/libpq/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@npmcli/run-script/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/jamlen/Library/Caches/node-gyp/14.19.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/jamlen/Library/Caches/node-gyp/14.19.0',
gyp info spawn args '-Dnode_gyp_dir=/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@npmcli/run-script/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/jamlen/Library/Caches/node-gyp/14.19.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/jamlen/dev/src/github.com/sst-demo/node_modules/libpq',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
/bin/sh: pg_config: command not found
gyp: Call to 'pg_config --libdir' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/jamlen/dev/src/github.com/tfgm/bus-reform-ticketing/node_modules/@npmcli/run-script/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/jamlen/.nvm/versions/node/v14.19.0/bin/node" "/Users/jamlen/dev/src/github.com/sst-demo/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/jamlen/dev/src/github.com/sst-demo/node_modules/libpq
gyp ERR! node -v v14.19.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
which led me to this GH issue which was closed as fixed in 2014! https://github.com/brianc/node-postgres/issues/684jamlen
04/29/2022, 8:00 AMjamlen
04/29/2022, 8:11 AMbrew install postgres
just so I can have the tools this thing needs… that’s a pain-in-the-arse and something I totally don’t need!Scott
05/01/2022, 2:19 AMScott
05/02/2022, 6:01 AMjamlen
05/12/2022, 8:44 PM