Build failing with gyp error

Hi my build is failing with a Gyp error which is rather interesting as I had the issue locally and I fixed it here is my build output

12:52:35 AM: Build ready to start
12:52:39 AM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
12:52:39 AM: build-image tag: v4.3.0
12:52:39 AM: buildbot version: ddbb47739f5b85c954aad9dc3823ab0676432957
12:52:39 AM: Fetching cached dependencies
12:52:39 AM: Failed to fetch cache, continuing with build
12:52:39 AM: Starting to prepare the repo for build
12:52:39 AM: No cached dependencies found. Cloning fresh repo
12:52:39 AM: git clone https://github.com/yepstein1/user_preferences
12:52:41 AM: Preparing Git Reference refs/heads/master
12:52:41 AM: Parsing package.json dependencies
12:52:42 AM: Starting build script
12:52:42 AM: Installing dependencies
12:52:42 AM: Python version set to 2.7
12:52:42 AM: Downloading and installing node v16.9.1...
12:52:43 AM: Downloading https://nodejs.org/dist/v16.9.1/node-v16.9.1-linux-x64.tar.xz...
12:52:43 AM: Computing checksum with sha256sum
12:52:43 AM: Checksums matched!
12:52:46 AM: Now using node v16.9.1 (npm v7.21.1)
12:52:46 AM: Started restoring cached build plugins
12:52:46 AM: Finished restoring cached build plugins
12:52:46 AM: Attempting ruby version 2.7.2, read from environment
12:52:48 AM: Using ruby version 2.7.2
12:52:48 AM: Using PHP version 8.0
12:52:48 AM: Started restoring cached node modules
12:52:48 AM: Finished restoring cached node modules
12:52:48 AM: Installing NPM modules using NPM version 7.21.1
12:53:38 AM: npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
12:53:38 AM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
12:53:39 AM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
12:53:39 AM: npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
12:53:39 AM: npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
12:53:40 AM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
12:53:40 AM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
12:53:40 AM: npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
12:53:41 AM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
12:53:42 AM: npm WARN deprecated rollup-plugin-babel@4.4.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel.
12:53:45 AM: npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
12:53:46 AM: npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
12:53:46 AM: npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
12:53:50 AM: npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
12:53:53 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
12:53:54 AM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
12:53:54 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
12:53:57 AM: npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
12:54:00 AM: npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
12:54:09 AM: npm ERR! code 1
12:54:09 AM: npm ERR! path /opt/build/repo/node_modules/libpq
12:54:09 AM: npm ERR! command failed
12:54:09 AM: npm ERR! command sh -c node-gyp rebuild
12:54:09 AM: npm ERR! gyp info it worked if it ends with ok
12:54:09 AM: npm ERR! gyp info using node-gyp@7.1.2
12:54:09 AM: npm ERR! gyp info using node@16.9.1 | linux | x64
12:54:09 AM: npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
12:54:09 AM: npm ERR! gyp http GET https://nodejs.org/download/release/v16.9.1/node-v16.9.1-headers.tar.gz
12:54:09 AM: npm ERR! gyp http 200 https://nodejs.org/download/release/v16.9.1/node-v16.9.1-headers.tar.gz
12:54:09 AM: npm ERR! gyp http GET https://nodejs.org/download/release/v16.9.1/SHASUMS256.txt
12:54:09 AM: npm ERR! gyp http 200 https://nodejs.org/download/release/v16.9.1/SHASUMS256.txt
12:54:09 AM: npm ERR! (node:1333) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
12:54:09 AM: npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
12:54:09 AM: npm ERR! gyp info spawn /usr/bin/python3
12:54:09 AM: npm ERR! gyp info spawn args [
12:54:09 AM: npm ERR! gyp info spawn args   '/opt/buildhome/.nvm/versions/node/v16.9.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
12:54:09 AM: npm ERR! gyp info spawn args   'binding.gyp',
12:54:09 AM: npm ERR! gyp info spawn args   '-f',
12:54:09 AM: npm ERR! gyp info spawn args   'make',
12:54:09 AM: npm ERR! gyp info spawn args   '-I',
12:54:09 AM: npm ERR! gyp info spawn args   '/opt/build/repo/node_modules/libpq/build/config.gypi',
12:54:09 AM: npm ERR! gyp info spawn args   '-I',
12:54:09 AM: npm ERR! gyp info spawn args   '/opt/buildhome/.nvm/versions/node/v16.9.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
12:54:09 AM: npm ERR! gyp info spawn args   '-I',
12:54:09 AM: npm ERR! gyp info spawn args   '/opt/buildhome/.cache/node-gyp/16.9.1/include/node/common.gypi',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dvisibility=default',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dnode_root_dir=/opt/buildhome/.cache/node-gyp/16.9.1',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/buildhome/.nvm/versions/node/v16.9.1/lib/node_modules/npm/node_modules/node-gyp',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dnode_lib_file=/opt/buildhome/.cache/node-gyp/16.9.1/<(target_arch)/node.lib',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dmodule_root_dir=/opt/build/repo/node_modules/libpq',
12:54:09 AM: npm ERR! gyp info spawn args   '-Dnode_engine=v8',
12:54:09 AM: npm ERR! gyp info spawn args   '--depth=.',
12:54:09 AM: npm ERR! gyp info spawn args   '--no-parallel',
12:54:09 AM: npm ERR! gyp info spawn args   '--generator-output',
12:54:09 AM: npm ERR! gyp info spawn args   'build',
12:54:09 AM: npm ERR! gyp info spawn args   '-Goutput_dir=.'
12:54:09 AM: npm ERR! gyp info spawn args ]
12:54:09 AM: npm ERR! find: ‘/usr/pg*’: No such file or directory
12:54:09 AM: 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
12:54:09 AM: npm ERR! gyp ERR! configure error
12:54:09 AM: npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
12:54:09 AM: npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/opt/buildhome/.nvm/versions/node/v16.9.1/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
12:54:09 AM: Creating deploy upload records
12:54:09 AM: npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
12:54:09 AM: npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
12:54:09 AM: npm ERR! gyp ERR! System Linux 4.19.167+
12:54:09 AM: npm ERR! gyp ERR! command "/opt/buildhome/.nvm/versions/node/v16.9.1/bin/node" "/opt/buildhome/.nvm/versions/node/v16.9.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
12:54:09 AM: npm ERR! gyp ERR! cwd /opt/build/repo/node_modules/libpq
12:54:09 AM: npm ERR! gyp ERR! node -v v16.9.1
12:54:09 AM: npm ERR! gyp ERR! node-gyp -v v7.1.2
12:54:09 AM: npm ERR! gyp ERR! not ok
12:54:09 AM: npm ERR! A complete log of this run can be found in:
12:54:09 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-15T04_54_09_062Z-debug.log
12:54:09 AM: Error during NPM install
12:54:09 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:54:09 AM: Build was terminated: Build script returned non-zero exit code: 1
12:54:09 AM: Failing build: Failed to build site
12:54:09 AM: Finished processing build request in 1m29.976539779s

my site name is sad-ride-ceece0
I would really appreciate any help, thanks!

Hi,

Could you try setting an environment variable with the name NODE_VERSION and value 14.17.5?

Hi i tried that but to no avail.

Hi @yepstein1

Are you able to share your git repository?

Can you share the link to your deploy log (if logs are public)?

Git is currently private. I suppose I can change it. Didn’t I paste build logs in my original post?

Which site is this regarding?

the site is # sad-ride-ceece0

this is repo GitHub - yepstein1/user_preferences

Hi @yepstein1,

If you look closely, the error is actually different this time:

It’s trying to find some file. Any idea what it might be?

hmm it looks like it is related to my node package to interact with posgressql… which is working locally

yepstein1, can you give us a bit more detail on what you are hoping to do with postgres? Netlify doesn’t provide the capability to run postgres on our servers, so this approach may not work the way you are hoping to :slight_smile:

I am calling postgres procedures from Netlify Functions. You can’t do that either?

you should be able to, but there may be some concerns about maintaining the connection - this thread might be relevant.

at either rate, it doesn’t really explain why you can’t at least install the package, but, if what you are hoping to do isn’t feasible anyway, we might not have to fix the first problem :slight_smile:

I would guess for my purposes it should just be fine. ( as long as it installs)
Why would something install locally and not on Netlify?

Lots of reasons:

  1. Netlify is running a Docker container and not an actual computer with access to all system-level tools.
  2. You get root or sudo permissions on your system, not on Netlify.
  3. Libraries might be incompatible with the versions of tools in our build image.
  4. Bug(s) in one (or many) of the tools that are present in the build image or in the library being used.

There might be more, but you get the point.

About the problem at hand, I found this:

Following the links and going to another links from those, helped me land on various other threads, but none of them seem to have a definite solution. I tried installing libpq using Brew on Netlify, but that didn’t help too.

On a related note, I also found this: Timescale Documentation | About psql which talks about various ways of installing some tools on the systems. Maybe something from that helps?

With that being said, if you do find a solution, it would be great if you could let us know.

1 Like

Hy @yepstein1 did you manage to resolve this issue. I’m getting same issue.