Postgres libpq dependencies failing on deploy

I have an Express postgres app I have been trying to deploy for two days. There are similar posts on this subject, but none of the solutions have works.

App: :// app.netlify. com/sites/astonishing-mochi

Similar issue (solution didn’t work): ://answers.netlify.com/t/continues-deployment-of-functions-with-postgresql/44730/29

I there anything else I can do? I can’t think of any other workarounds. My alternatives seem to be find a different provider than Netlify or switch to a different database solution?

Full deploy log:
2:45:09 PM: build-image version: 68a2c262fa3c95a08a1716b8dde8fba0e332ec73 (focal)
2:45:09 PM: buildbot version: b549e06c0b968ceb54ca53dc179c6fe57df02730
2:45:09 PM: Fetching cached dependencies
2:45:09 PM: Failed to fetch cache, continuing with build
2:45:09 PM: Starting to prepare the repo for build
2:45:09 PM: No cached dependencies found. Cloning fresh repo
2:45:09 PM: git clone --filter=blob:none ://github.com/krakenxiv/todo-ejs-postgres-api-concept
2:45:09 PM: Preparing Git Reference pull/9/head
2:45:10 PM: Parsing package.json dependencies
2:45:11 PM:

❯ Initial build environment
baseRelDir: true
branch: fix-npm-version
context: deploy-preview
cwd: /opt/build/repo
featureFlags:
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: 40629db9-c632-4c9f-b201-5fc4f977291e

❯ UI build settings
baseRelDir: true
build:
command: npm run build
environment:
- NETLIFY_BUILD_DEBUG
- NODE_VERSION
- NPM_FLAGS
- NPM_VERSION
- REVIEW_ID
- SBASE_DB
- SBASE_HOST
- SBASE_PORT
- SBASE_PW
- SBASE_USER
- TODO_DATA_HOST
- TODO_UI_LOCAL_HOST
publish: dist/

❯ Resolved build environment
branch: fix-npm-version
buildDir: /opt/build/repo
configPath: /opt/build/repo/netlify.toml
context: deploy-preview
env:

❯ Resolved config
build:
command: npm run build
commandOrigin: ui
environment:
- NETLIFY_BUILD_DEBUG
- NODE_VERSION
- NPM_FLAGS
- NPM_VERSION
- REVIEW_ID
- SBASE_DB
- SBASE_HOST
- SBASE_PORT
- SBASE_PW
- SBASE_USER
- TODO_DATA_HOST
- TODO_UI_LOCAL_HOST
publish: /opt/build/repo/dist
publishOrigin: ui
functionsDirectory: /opt/build/repo/functions

2:45:11 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: ‘functions’ versus ‘’ in the Netlify UI
2:45:11 PM: Starting to install dependencies
2:45:12 PM: Python version set to 3.8
2:45:12 PM: Attempting Ruby version 2.7.2, read from environment
2:45:12 PM: Using Ruby version 2.7.2
2:45:13 PM: Started restoring cached go cache
2:45:13 PM: Finished restoring cached go cache
2:45:13 PM: Installing Go version 1.19.5 (requested 1.19.5)
2:45:17 PM: go version go1.19.5 linux/amd64
2:45:18 PM: Using PHP version 8.0
2:45:18 PM: Attempting Node.js version ‘v18.15.0’ from .nvmrc
2:45:19 PM: Downloading and installing node v18.15.0…
2:45:19 PM: Downloading ://nodejs.org/dist/v18.15.0/node-v18.15.0-linux-x64.tar.xz…
2:45:19 PM: Computing checksum with sha256sum
2:45:19 PM: Checksums matched!
2:45:21 PM: Now using node v18.15.0 (npm v9.5.0)
2:45:21 PM: Enabling Node.js Corepack
2:45:21 PM: Started restoring cached build plugins
2:45:21 PM: Finished restoring cached build plugins
2:45:21 PM: Started restoring cached corepack dependencies
2:45:21 PM: Finished restoring cached corepack dependencies
2:45:22 PM: No npm workspaces detected
2:45:22 PM: Started restoring cached node modules
2:45:22 PM: Finished restoring cached node modules
2:45:22 PM: Found npm version (9.5.0) that doesn’t match expected (9.6.2)
Installing npm version 9.6.2
2:45:24 PM: changed 29 packages in 1s
2:45:24 PM: 16 packages are looking for funding
2:45:24 PM: run npm fund for details
2:45:24 PM: npm installed successfully
2:45:24 PM: Installing npm packages using npm version 9.6.2
2:45:31 PM: npm ERR! code 1
2:45:31 PM: npm ERR! path /opt/build/repo/node_modules/libpq
2:45:31 PM: npm ERR! command failed
2:45:31 PM: npm ERR! command sh -c node-gyp rebuild
2:45:31 PM: npm ERR! gyp info it worked if it ends with ok
2:45:31 PM: Failed during stage ‘Install dependencies’: dependency_installation script returned non-zero exit code: 1
2:45:31 PM: npm ERR! gyp info using node-gyp@9.3.1
2:45:31 PM: npm ERR! gyp info using node@18.15.0 | linux | x64
2:45:31 PM: npm ERR! gyp info find Python using Python version 3.8.10 found at “/opt/buildhome/python3.8/bin/python3”
2:45:31 PM: npm ERR! gyp http GET ://nodejs.org/download/release/v18.15.0/node-v18.15.0-headers.tar.gz
2:45:31 PM: npm ERR! gyp http 200 ://nodejs.org/download/release/v18.15.0/node-v18.15.0-headers.tar.gz
2:45:31 PM: npm ERR! gyp http GET ://nodejs.org/download/release/v18.15.0/SHASUMS256.txt
2:45:31 PM: npm ERR! gyp http 200 ://nodejs.org/download/release/v18.15.0/SHASUMS256.txt
2:45:31 PM: npm ERR! gyp info spawn /opt/buildhome/python3.8/bin/python3
2:45:31 PM: npm ERR! gyp info spawn args [
2:45:31 PM: npm ERR! gyp info spawn args ‘/opt/buildhome/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py’,
2:45:31 PM: npm ERR! gyp info spawn args ‘binding.gyp’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-f’,
2:45:31 PM: npm ERR! gyp info spawn args ‘make’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-I’,
2:45:31 PM: npm ERR! gyp info spawn args ‘/opt/build/repo/node_modules/libpq/build/config.gypi’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-I’,
2:45:31 PM: npm ERR! gyp info spawn args ‘/opt/buildhome/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-I’,
2:45:31 PM: npm ERR! gyp info spawn args ‘/opt/buildhome/.cache/node-gyp/18.15.0/include/node/common.gypi’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dlibrary=shared_library’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dvisibility=default’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dnode_root_dir=/opt/buildhome/.cache/node-gyp/18.15.0’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dnode_gyp_dir=/opt/buildhome/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dnode_lib_file=/opt/buildhome/.cache/node-gyp/18.15.0/<(target_arch)/node.lib’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dmodule_root_dir=/opt/build/repo/node_modules/libpq’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Dnode_engine=v8’,
2:45:31 PM: npm ERR! gyp info spawn args ‘–depth=.’,
2:45:31 PM: npm ERR! gyp info spawn args ‘–no-parallel’,
2:45:31 PM: npm ERR! gyp info spawn args ‘–generator-output’,
2:45:31 PM: npm ERR! gyp info spawn args ‘build’,
2:45:31 PM: npm ERR! gyp info spawn args ‘-Goutput_dir=.’
2:45:31 PM: npm ERR! gyp info spawn args ]
2:45:31 PM: npm ERR! find: ‘/usr/pg*’: No such file or directory
2:45:31 PM: npm ERR! gyp: Call to ‘which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit’ returned exit status 1 while in binding.gyp. while trying to load binding.gyp
2:45:31 PM: npm ERR! gyp ERR! configure error
2:45:31 PM: npm ERR! gyp ERR! stack Error: gyp failed with exit code: 1
2:45:31 PM: npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/opt/buildhome/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:325:16)
2:45:31 PM: npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
2:45:31 PM: npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
2:45:31 PM: npm ERR! gyp ERR! System Linux 5.4.228-131.415.amzn2.x86_64
2:45:31 PM: npm ERR! gyp ERR! command “/opt/buildhome/.nvm/versions/node/v18.15.0/bin/node” “/opt/buildhome/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
2:45:31 PM: npm ERR! gyp ERR! cwd /opt/build/repo/node_modules/libpq
2:45:31 PM: npm ERR! gyp ERR! node -v v18.15.0
2:45:31 PM: npm ERR! gyp ERR! node-gyp -v v9.3.1
2:45:31 PM: npm ERR! gyp ERR! not ok
2:45:31 PM: npm ERR! A complete log of this run can be found in:
2:45:31 PM: npm ERR! /opt/buildhome/.npm/_logs/2023-04-25T21_45_24_991Z-debug-0.log
2:45:31 PM: Error during npm install
2:45:31 PM: Build was terminated: dependency_installation script returned non-zero exit code: 1
2:45:31 PM: Failing build: Failed to install dependencies
2:45:32 PM: Finished processing build request in 22.901s

Quite likely this is an issue with libpq as mentioned in

Downgrading the node version Netlify build is using may (or may not) solve this.

Have you tried switching to another library as mentioned in the thread you linked to?

Hey- thanks for reaching out. A few things I’ve tried:

-Downgrading to a different node version. I tried several, they did not fix the issue.
-Using the other library as suggested in the other thread. I could not get it to work, and documentation was minimal. I could not find any working example of an app that was using it successfully.
-I tried overriding the default version of libpq using package.json overrides. This did not work.
-I tried using an NPM_FLAGS environment variable to force the node install.
-I tried using yarn instead of npm.

Hi, I am not seeing this site on your account. Can you please provide a site ID?

Hey Sam- I ended up moving this to a different provider because I could not find any path forward after a ton of digging and a ton of research. The problem seems to be on the libpq side, but I couldn’t find any way to make the app work on the Netlify side. Still running the front-end on Netlify.

Thanks for reaching out.

Tim

1 Like