thiagoelg / node-printer

Native node.js printer
125 stars 76 forks source link

Failed installation in Alpine Linux distribution #17

Closed manuelnucci closed 3 years ago

manuelnucci commented 3 years ago

Hi, I'm trying to install the library in a NodeJS docker image based on Alpine Linux.

In order to do that, I installed the required dependencies with this command:

FROM node:12.18.3-alpine3.12 AS build
RUN apk --no-cache add python3 cups-dev
...

However, the installation of the library fails later. Here is the log:

error /home/node/app/node_modules/@thiagoelg/node-printer: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments:
Directory: /home/node/app/node_modules/@thiagoelg/node-printer
Output:
prebuild-install WARN install No prebuilt binaries found (target=12.18.3 runtime=node arch=x64 libc=musl platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@12.18.3 | linux | x64
gyp info find Python using Python version 3.8.5 found at "/usr/bin/python3"
gyp http GET https://unofficial-builds.nodejs.org/download/release/v12.18.3/node-v12.18.3-headers.tar.gz
gyp http 200 https://unofficial-builds.nodejs.org/download/release/v12.18.3/node-v12.18.3-headers.tar.gz
gyp http GET https://unofficial-builds.nodejs.org/download/release/v12.18.3/SHASUMS256.txt
gyp http 200 https://unofficial-builds.nodejs.org/download/release/v12.18.3/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/node/app/node_modules/@thiagoelg/node-printer/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/node/.cache/node-gyp/12.18.3/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/node/.cache/node-gyp/12.18.3',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/node/.cache/node-gyp/12.18.3/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/node/app/node_modules/@thiagoelg/node-printer',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: [Errno 2] No such file or directory: 'python' while executing command '['python', 'tools/getSourceFiles.py', 'src', 'cc']' in binding.gyp 
while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.19.128-microsoft-standard
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/node/app/node_modules/@thiagoelg/node-printer
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Service 'app' failed to build : The command '/bin/sh -c yarn install --frozen-lockfile && yarn cache clean' returned a non-zero code: 1

I'm not sure which is the problem, but, for what I can tell, it isn't something related with missing dependencies.

I hope someone can give me a hint.

jfollmann commented 3 years ago

+1

thiagoelg commented 3 years ago

Hey guys, sorry I didn't see this earlier. This line from the stacktrace is really useful:

gyp: [Errno 2] No such file or directory: 'python' while executing command '['python', 'tools/getSourceFiles.py', 'src', 'cc']' in binding.gyp 
while trying to load binding.gyp

For building/installing this lib python is necessary (required by node-gyp), so installing python on your Alpine Linux should probably fix the issue.