docker-node: Latest docker build breaks node-gyp in node-18
Environment
- Platform:
- Docker Version:
- Node.js Version:
- Image Tag: 18-alpine
(This happens inside my managed CI provider, not sure on its version)
Current Behavior
When I install sharp, it fails due to node gyp:
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /usr/app/node_modules/cpu-features
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@10.0.1
gyp info using node@18.19.0 | linux | x64
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if \"python3\" can be used
gyp ERR! find Python - executable path is \"\"
gyp ERR! find Python - \"\" could not be run
gyp ERR! find Python checking if \"python\" can be used
gyp ERR! find Python - executable path is \"\"
gyp ERR! find Python - \"\" could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python=\"/path/to/pythonexecutable\"
gyp ERR! find Python (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python npm config set python \"/path/to/pythonexecutable\"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:306:11)
gyp ERR! stack at PythonFinder.findPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:164:17)
gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
gyp ERR! stack at async configure (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:23:18)
gyp ERR! stack at async run (/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:81:18)
gyp ERR! System Linux 6.2.0-1015-aws
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 /usr/app/node_modules/cpu-features
gyp ERR! node -v v18.19.0
gyp ERR! node-gyp -v v10.0.1
gyp ERR! not ok"
2023-12-12 14:02:50
info This module is OPTIONAL, you can safely ignore this error
2023-12-12 14:02:50
error /usr/app/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /usr/app/node_modules/sharp
Output:
sharp: Installation error: Invalid Version: 1.2.4_git20230717
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
This was working yesterday and seems to coincide with this build going live:
When I stick my docker version to the node:18-alpine3.18 it works again.
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 7
- Comments: 16 (2 by maintainers)
Commits related to this issue
- ci: pin node docker image Related issue: https://github.com/nodejs/docker-node/issues/2009 — committed to Blobscan/blobscan by PabloCastellano 6 months ago
- fix(Dockerfile): use old alpine to avoid node-gyp compile Ref: https://github.com/nodejs/docker-node/issues/2009#issuecomment-1854568831 — committed to cofacts/rumors-api by MrOrz 6 months ago
- fix: fix a version issue that happens on the newer builds of alpine-lunix Originally, I stumbled on an error with `../src/pipeline.cc` where it complained about an invalid struct type. After some ... — committed to raphaelluethy/documentation by raphaelluethy 3 months ago
- fix: fix a version issue that happens on the newer builds of alpine-lunix (#2063) Originally, I stumbled on an error with `../src/pipeline.cc` where it complained about an invalid struct type. Aft... — committed to strapi/documentation by raphaelluethy 3 months ago
I confirm the problem using node:18-alpine3.19
Running
npm i
this is the problem shown:Downgrade to node:18-alpine3.18 it works.
I downgraded to
node:18-alpine3.18
and everything is work for now, I’ll continue to follow this issue to upgrade when I canAh, for some, this looks like a sharp module incompatibility with the newer
libvips
of the Alpine packages. In Alpine 3.18,libvips
is8.13.3
, but it is8.15.0
in Alpine 3.19 (https://pkgs.alpinelinux.org/packages?name=vips-dev&branch=v3.19).https://github.com/lovell/sharp/blob/v0.30.7/package.json#L157 https://github.com/lovell/sharp/blob/v0.31.3/package.json#L158 https://github.com/lovell/sharp/blob/v0.32.6/package.json#L162 https://github.com/lovell/sharp/blob/v0.33.0/package.json#L190
I think just updating your sharp dependency should be enough in some cases:
working on
node:21-alpine3.18
@nschonni I tried following those instructions using
node:20-alpine
, I had the same build error until I switched tonode:20-alpine3.18
without those extra apt packages being installed.The Alpine image never supported node-gyp building without additional packages being added. Instructions can be found here https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine Likely the Sharp or other packages were shipping pre-built binaries that aren’t currently compatible with the newest Alpine image, no change in this repo will fix that.