'Heroku build failing on poppler node module

I've been working on this for a few days now.

I have a Node app that I am trying to deploy to Heroku. It has calipers-pdf as a dependency which is causing a hang-up on build specifically the down stream dependency of poppler.

In order to get through this locally I needed to brew install poppler as noted by the Readme for Calipers. Obviously on Heroku I can't do much brewing so I began learning about using multiple buildpacks which gave me some progress. I began having trouble with the $PKG_CONFIG_PATH and pkg-config not found errors. This lead me down the Aptfile path which made some progress and leaves me at my current sticking point. It's not finding cpp/poppler-version.h which I've run a find for and can confirm doesn't exist. Every variation of 'poppler' and 'heroku' that I can think of to Google pulls up nothing but purple links at this point so I could use a pointer.

Failed Build Output:

TL;DR: npm ERR! ../src/NodePopplerDocument.h:4:10: fatal error: cpp/poppler-version.h: No such file or directory

remote: Compressing source files... done.        
remote: Building source:        
remote: 
remote: -----> Building on the Heroku-20 stack        
remote: -----> Using buildpacks:        
remote:        1. https://github.com/sight-visit/heroku-buildpack-poppler        
remote:        2. https://github.com/heroku/heroku-buildpack-apt        
remote:        3. heroku/nodejs        
remote: -----> https://github.com/sight-visit/heroku-buildpack-poppler app detected        
remote: Extracting poppler_21.05.0-1_amd64.deb...        
remote: Done        
remote: -----> Apt app detected        
remote: -----> Detected Aptfile or Stack changes, flushing cache        
remote: -----> Updating apt caches        
remote:        Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]        
remote:        Get:2 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease [86.6 kB]        
remote:        Get:3 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]        
remote:        Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]        
remote:        Get:5 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]        
remote:        Get:6 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 Packages [365 kB]        
remote:        Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1,275 kB]        
remote:        Get:8 http://archive.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,645 kB]        
remote:        Get:9 http://archive.ubuntu.com/ubuntu focal-security/universe amd64 Packages [858 kB]        
remote:        Get:10 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,141 kB]        
remote:        Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,059 kB]        
remote:        Fetched 19.3 MB in 2s (8,575 kB/s)        
remote:        Reading package lists...        
remote: -----> Fetching .debs for poppler-utils        
remote:        Reading package lists...        
remote:        Building dependency tree...        
remote:        The following additional packages will be installed:        
remote:          libnspr4 libnss3 libpoppler97        
remote:        The following NEW packages will be installed:        
remote:          libnspr4 libnss3 libpoppler97 poppler-utils        
remote:        0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.        
remote:        Need to get 2,452 kB of archives.        
remote:        After this operation, 8,661 kB of additional disk space will be used.        
remote:        Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libnspr4 amd64 2:4.25-1 [107 kB]        
remote:        Get:2 http://archive.ubuntu.com/ubuntu focal-security/main amd64 libnss3 amd64 2:3.49.1-1ubuntu1.6 [1,256 kB]        
remote:        Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 libpoppler97 amd64 0.86.1-0ubuntu1 [915 kB]        
remote:        Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 poppler-utils amd64 0.86.1-0ubuntu1 [174 kB]        
remote:        Fetched 2,452 kB in 1s (3,164 kB/s)        
remote:        Download complete and in download only mode        
remote: -----> Fetching .debs for poppler-data        
remote:        Reading package lists...        
remote:        Building dependency tree...        
remote:        0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 2 not upgraded.        
remote:        Need to get 1,475 kB of archives.        
remote:        After this operation, 0 B of additional disk space will be used.        
remote:        Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 poppler-data all 0.4.9-2 [1,475 kB]        
remote:        Fetched 1,475 kB in 1s (2,237 kB/s)        
remote:        Download complete and in download only mode        
remote: -----> Fetching .debs for pkg-config        
remote:        Reading package lists...        
remote:        Building dependency tree...        
remote:        0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 2 not upgraded.        
remote:        Need to get 45.5 kB of archives.        
remote:        After this operation, 0 B of additional disk space will be used.        
remote:        Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 pkg-config amd64 0.29.1-0ubuntu4 [45.5 kB]        
remote:        Fetched 45.5 kB in 0s (152 kB/s)        
remote:        Download complete and in download only mode        
remote: -----> Fetching .debs for build-essential        
remote:        Reading package lists...        
remote:        Building dependency tree...        
remote:        0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 2 not upgraded.        
remote:        Need to get 4,664 B of archives.        
remote:        After this operation, 0 B of additional disk space will be used.        
remote:        Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 build-essential amd64 12.8ubuntu1.1 [4,664 B]        
remote:        Fetched 4,664 B in 0s (30.2 kB/s)        
remote:        Download complete and in download only mode        
remote: -----> Fetching .debs for libpoppler-cpp-dev        
remote:        Reading package lists...        
remote:        Building dependency tree...        
remote:        The following additional packages will be installed:        
remote:          libnspr4 libnss3 libpoppler-cpp0v5 libpoppler-dev libpoppler97        
remote:        The following NEW packages will be installed:        
remote:          libnspr4 libnss3 libpoppler-cpp-dev libpoppler-cpp0v5 libpoppler-dev        
remote:          libpoppler97        
remote:        0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.        
remote:        Need to get 51.3 kB/2,330 kB of archives.        
remote:        After this operation, 8,176 kB of additional disk space will be used.        
remote:        Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libpoppler-cpp0v5 amd64 0.86.1-0ubuntu1 [35.6 kB]        
remote:        Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libpoppler-dev amd64 0.86.1-0ubuntu1 [5,336 B]        
remote:        Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 libpoppler-cpp-dev amd64 0.86.1-0ubuntu1 [10.4 kB]        
remote:        Fetched 51.3 kB in 0s (171 kB/s)        
remote:        Download complete and in download only mode        
remote: -----> Installing build-essential_12.8ubuntu1.1_amd64.deb        
remote: -----> Installing libnspr4_2%3a4.25-1_amd64.deb        
remote: -----> Installing libnss3_2%3a3.49.1-1ubuntu1.6_amd64.deb        
remote: -----> Installing libpoppler97_0.86.1-0ubuntu1_amd64.deb        
remote: -----> Installing libpoppler-cpp0v5_0.86.1-0ubuntu1_amd64.deb        
remote: -----> Installing libpoppler-cpp-dev_0.86.1-0ubuntu1_amd64.deb        
remote: -----> Installing libpoppler-dev_0.86.1-0ubuntu1_amd64.deb        
remote: -----> Installing pkg-config_0.29.1-0ubuntu4_amd64.deb        
remote: -----> Installing poppler-data_0.4.9-2_all.deb        
remote: -----> Installing poppler-utils_0.86.1-0ubuntu1_amd64.deb        
remote: -----> Writing profile script        
remote: -----> Rewrite package-config files        
remote: -----> Node.js app detected        
remote:                
remote: -----> Creating runtime environment        
remote:                
remote:        NPM_CONFIG_LOGLEVEL=error        
remote:        NODE_VERBOSE=false        
remote:        NODE_ENV=production        
remote:        NODE_MODULES_CACHE=true        
remote:                
remote: -----> Installing binaries        
remote:        engines.node (package.json):  unspecified        
remote:        engines.npm (package.json):   unspecified (use default)        
remote:                
remote:        Resolving node version 16.x...        
remote:        Downloading and installing node 16.14.0...        
remote:        Using default npm version: 8.3.1        
remote:                
remote: -----> Installing dependencies        
remote:        Installing node modules        
remote:        npm ERR! code 1        
remote:        npm ERR! path /tmp/build_e9ca9c52/node_modules/poppler-simple        
remote:        npm ERR! command failed        
remote:        npm ERR! command sh -c (node-gyp rebuild) || (exit 1)        
remote:        npm ERR! make: Entering directory '/tmp/build_e9ca9c52/node_modules/poppler-simple/build'        
remote:        npm ERR!   CXX(target) Release/obj.target/poppler/src/poppler.o        
remote:        npm ERR! make: Leaving directory '/tmp/build_e9ca9c52/node_modules/poppler-simple/build'        
remote:        npm ERR! gyp info it worked if it ends with ok        
remote:        npm ERR! gyp info using [email protected]        
remote:        npm ERR! gyp info using [email protected] | linux | x64        
remote:        npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"        
remote:        npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/node-v16.14.0-headers.tar.gz        
remote:        npm ERR! gyp http 200 https://nodejs.org/download/release/v16.14.0/node-v16.14.0-headers.tar.gz        
remote:        npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/SHASUMS256.txt        
remote:        npm ERR! gyp http 200 https://nodejs.org/download/release/v16.14.0/SHASUMS256.txt        
remote:        npm ERR! gyp info spawn /usr/bin/python3        
remote:        npm ERR! gyp info spawn args [        
remote:        npm ERR! gyp info spawn args   '/tmp/build_e9ca9c52/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',        
remote:        npm ERR! gyp info spawn args   'binding.gyp',        
remote:        npm ERR! gyp info spawn args   '-f',        
remote:        npm ERR! gyp info spawn args   'make',        
remote:        npm ERR! gyp info spawn args   '-I',        
remote:        npm ERR! gyp info spawn args   '/tmp/build_e9ca9c52/node_modules/poppler-simple/build/config.gypi',        
remote:        npm ERR! gyp info spawn args   '-I',        
remote:        npm ERR! gyp info spawn args   '/tmp/build_e9ca9c52/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',        
remote:        npm ERR! gyp info spawn args   '-I',        
remote:        npm ERR! gyp info spawn args   '/app/.cache/node-gyp/16.14.0/include/node/common.gypi',        
remote:        npm ERR! gyp info spawn args   '-Dlibrary=shared_library',        
remote:        npm ERR! gyp info spawn args   '-Dvisibility=default',        
remote:        npm ERR! gyp info spawn args   '-Dnode_root_dir=/app/.cache/node-gyp/16.14.0',        
remote:        npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/tmp/build_e9ca9c52/.heroku/node/lib/node_modules/npm/node_modules/node-gyp',        
remote:        npm ERR! gyp info spawn args   '-Dnode_lib_file=/app/.cache/node-gyp/16.14.0/<(target_arch)/node.lib',        
remote:        npm ERR! gyp info spawn args   '-Dmodule_root_dir=/tmp/build_e9ca9c52/node_modules/poppler-simple',        
remote:        npm ERR! gyp info spawn args   '-Dnode_engine=v8',        
remote:        npm ERR! gyp info spawn args   '--depth=.',        
remote:        npm ERR! gyp info spawn args   '--no-parallel',        
remote:        npm ERR! gyp info spawn args   '--generator-output',        
remote:        npm ERR! gyp info spawn args   'build',        
remote:        npm ERR! gyp info spawn args   '-Goutput_dir=.'        
remote:        npm ERR! gyp info spawn args ]        
remote:        npm ERR! gyp info spawn make        
remote:        npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]        
remote:        npm ERR! In file included from ../src/poppler.cc:3:        
remote:        npm ERR! ../src/NodePopplerDocument.h:4:10: fatal error: cpp/poppler-version.h: No such file or directory        
remote:        npm ERR!     4 | #include <cpp/poppler-version.h>        
remote:        npm ERR!       |          ^~~~~~~~~~~~~~~~~~~~~~~        
remote:        npm ERR! compilation terminated.        
remote:        npm ERR! make: *** [poppler.target.mk:127: Release/obj.target/poppler/src/poppler.o] Error 1        
remote:        npm ERR! gyp ERR! build error         
remote:        npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2        
remote:        npm ERR! gyp ERR! stack     at ChildProcess.onExit (/tmp/build_e9ca9c52/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)        
remote:        npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)        
remote:        npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)        
remote:        npm ERR! gyp ERR! System Linux 4.4.0-1098-aws        
remote:        npm ERR! gyp ERR! command "/tmp/build_e9ca9c52/.heroku/node/bin/node" "/tmp/build_e9ca9c52/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"        
remote:        npm ERR! gyp ERR! cwd /tmp/build_e9ca9c52/node_modules/poppler-simple        
remote:        npm ERR! gyp ERR! node -v v16.14.0        
remote:        npm ERR! gyp ERR! node-gyp -v v8.4.1        
remote:        npm ERR! gyp ERR! not ok        
remote:                
remote:        npm ERR! A complete log of this run can be found in:        
remote:        npm ERR!     /tmp/npmcache.qXkSm/_logs/2022-03-11T15_28_09_176Z-debug-0.log        
remote: 
remote: -----> Build failed        
remote:                
remote:        We're sorry this build is failing! You can troubleshoot common issues here:        
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys        
remote:                
remote:        Some possible problems:        
remote:                
remote:        - Node version not specified in package.json        
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version        
remote:                
remote:        Love,        
remote:        Heroku        
remote:                
remote:  !     Push rejected, failed to compile Node.js app.        
remote: 
remote:  !     Push failed        
remote: Verifying deploy...        
remote: 
remote: !   Push rejected to fd-dashboard.        
remote: 
To https://git.heroku.com/fd-dashboard.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fd-dashboard.git'

package.json dependencies:

  "dependencies": {
    "calipers": "^2.0.1",
    "calipers-pdf": "^2.2.1",
    "cors": "^2.8.5",
    "express": "^4.17.3",
    "puppeteer": "^13.3.2"
  }

Heroku Setup:

Stack: Heroku-20

Aptfile:

poppler-utils
poppler-data
pkg-config
build-essential
libpoppler-cpp-dev

Buildpacks:

https://github.com/sight-visit/heroku-buildpack-poppler
https://github.com/heroku/heroku-buildpack-apt
heroku/nodejs


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source