ghostscript4js in firebase nodejs: /usr/lib/x86_64-linux-gnu/libgs.so: No such file or directory

Viewed 503

I'm trying to install this package to my firebase functions: https://www.npmjs.com/package/ghostscript-js

So I run:

npm install ghostscript-js

And it installs fine:

> ghostscript4js@3.2.1 install /Users/user/Work/MyApp/functions/node_modules/ghostscript4js
> node-gyp rebuild

  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
  CXX(target) Release/obj.target/ghostscript4js/src/ghostscript4js.o
  SOLINK_MODULE(target) Release/ghostscript4js.node
+ ghostscript4js@3.2.1
added 4 packages from 57 contributors and audited 14412 packages in 7.161s

But when I deploy it to firebase it crashes with error: /usr/lib/x86_64-linux-gnu/libgs.so: No such file or directory:

firebase deploy

Console log:

Deployment error.
Build failed: 
{
  "error": {
    "canonicalCode": "INVALID_ARGUMENT",
    "errorMessage": "`npm_install` had stderr output:
    node-pre-gyp WARN 
    Using request for node-pre-gyp https download 
    g++: error: /usr/lib/x86_64-linux-gnu/libgs.so: No such file or directory
    make: *** [Release/obj.target/ghostscript4js.node] Error 1
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
    gyp ERR! stack     at emitTwo (events.js:126:13)
    gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
    gyp ERR! System Linux 4.15.0-1044-gcp
    gyp ERR! command \"/usr/bin/node\" \"/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
    gyp ERR! cwd /workspace/node_modules/ghostscript4js
    gyp ERR! node -v v8.16.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok 
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! ghostscript4js@3.2.1 install: `node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the ghostscript4js@3.2.1 install script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /builder/home/.npm/_logs/2020-03-09T10_06_18_268Z-debug.log
    error: `npm_install` returned code: 1",
    "errorType": "InternalError",
    "errorId": "F8BCC123"
  }
}

I was trying to override --GS4JS_HOME but then it fails during the npm install ghostscript-js.

Any input on what I'm missing and doing wrong here?

1 Answers

The problem apparently was that it's required to install the underlying ghostscript to the node environment - ghostscript4js is just a wrapper.

I gave up on ghostscript4js and started to use ghostscript directly after installing it.

Also here is the link on how I installed it in my case (I'm using firebase node) if that might help anybody too:

https://tech.residebrokerage.com/using-firebase-cloud-functions-with-ghostscript-for-pdf-to-image-conversion-f81b248d3b22

Different node environments might require different steps to install it.

Related