node-postgres issue
I saw in the changelog:
The node-postgres
(pg) driver is now supported for Pages applications using Hyperdrive.
But I can't get node-postgres to work on Pages. It works locally, but when I try to deploy I get:
Error: Build failed with 10 errors:
../node_modules/pg-connection-string/index.js:76:77: ERROR: Could not resolve "fs"
../node_modules/pg/lib/connection-parameters.js:3:18: ERROR: Could not resolve "dns"
../node_modules/pg/lib/connection.js:94:24: ERROR: Could not resolve "net"
../node_modules/pg/lib/crypto/utils-legacy.js:5:27: ERROR: Could not resolve "crypto"
../node_modules/pg/lib/crypto/utils-webcrypto.js:1:27: ERROR: Could not resolve "crypto"
...
at failureErrorWithLog (/Users/steve/dev/egg-wars-2/node_modules/esbuild/lib/main.js:1636:15)
at /Users/steve/dev/egg-wars-2/node_modules/esbuild/lib/main.js:1048:25
at /Users/steve/dev/egg-wars-2/node_modules/esbuild/lib/main.js:1512:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [
{
detail: undefined,
id: '',
location: {
column: 77,
file: '../node_modules/pg-connection-string/index.js',
length: 4,
line: 76,
lineText: " const fs = config.sslcert || config.sslkey || config.sslrootcert ? require('fs') : null",
namespace: '',
suggestion: ''
},
notes: [
{
location: null,
text: `The package "fs" wasn't found on the file system but is built into node.\n` +
'Add the "nodejs_compat" compatibility flag to your Pages project and make sure to prefix the module name with "node:" to enable Node.js compatibility.'
}
],
pluginName: '',
text: 'Could not resolve "fs"'
},
Error: Build failed with 10 errors:
../node_modules/pg-connection-string/index.js:76:77: ERROR: Could not resolve "fs"
../node_modules/pg/lib/connection-parameters.js:3:18: ERROR: Could not resolve "dns"
../node_modules/pg/lib/connection.js:94:24: ERROR: Could not resolve "net"
../node_modules/pg/lib/crypto/utils-legacy.js:5:27: ERROR: Could not resolve "crypto"
../node_modules/pg/lib/crypto/utils-webcrypto.js:1:27: ERROR: Could not resolve "crypto"
...
at failureErrorWithLog (/Users/steve/dev/egg-wars-2/node_modules/esbuild/lib/main.js:1636:15)
at /Users/steve/dev/egg-wars-2/node_modules/esbuild/lib/main.js:1048:25
at /Users/steve/dev/egg-wars-2/node_modules/esbuild/lib/main.js:1512:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [
{
detail: undefined,
id: '',
location: {
column: 77,
file: '../node_modules/pg-connection-string/index.js',
length: 4,
line: 76,
lineText: " const fs = config.sslcert || config.sslkey || config.sslrootcert ? require('fs') : null",
namespace: '',
suggestion: ''
},
notes: [
{
location: null,
text: `The package "fs" wasn't found on the file system but is built into node.\n` +
'Add the "nodejs_compat" compatibility flag to your Pages project and make sure to prefix the module name with "node:" to enable Node.js compatibility.'
}
],
pluginName: '',
text: 'Could not resolve "fs"'
},
1 Reply
I'm using
"pg": "8.13.0",