-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Environment
- Platform: Any
- Docker Version: Any
- Node.js Version: Any, but especially the 16.x series if NPM decides to adopt node-gyp@8 (See discussion here: Heads-up: npm may be looking to adopt node-gyp version 8.x soon node-gyp#2392).
- Image Tag: Any, but especially the
node:16
Debian Stretch-based tag if NPM adopts node-gyp@8, see issue linked above.
Expected Behavior
Python 3 on the official NodeJS Docker images should be new enough to run node-gyp@8 (should be Python 3.6 or newer, see nodejs/node-gyp#2333.)
For reference, node-gyp
is the most widely-used native (C/C++) code build tool in the NodeJS ecosystem, used to build native code addons for JS Node modules, which are also popularly known as npm packages. node-gyp@8 is the latest major version of node-gyp as of when I'm posting this issue.
Current Behavior
The Debian Stretch-based, default image tags (node:12
, node:14
, node:16
) ship the same Python 3.5.3 that comes with Debian Stretch itself.
That is too old for node-gyp@8; node-gyp@8 rebuild
fails due to requiring newer Python than that.
Possible Solution
Add a step to the image definition that adds Python 3.6.x or newer. This should be available as the first python3
on the PATH.
It's possible to do so while still shipping a copy of python3.5
for those who might need it, I suppose.
Steps to Reproduce
$ sudo docker run --rm -it node:14 bash
root@f27b1d9f6da7:/# mkdir fails_to_build && cd fails_to_build
root@f27b1d9f6da7:/fails_to_build# npm install superstring --jobs=MAX
### [builds successfully using npm 6.x's bundled copy of node-gyp@5]
root@f27b1d9f6da7:/fails_to_build# npx node-gyp@latest rebuild --jobs=MAX
### [node-gyp@8 build failure message here due to outdated Python 3.5.3]
Additional Information
The NPM team have been carefully weighing whether to adopt node-gyp@8 in npm@7 and how/when to do so. If they do, that will likely be picked up in the Node 16.x series and newer in due time.
See discussion here: nodejs/node-gyp#2392
If NPM and Node decide to do that soon, it could leave users of the node:16
tag with broken node-gyp@8
--> broken package installs, due to incompatible/outdated Python 3.5.3 shipping in the image.
As mentioned in the above-linked issue, users of the latest pnpm
are already affected on the Stretch-based images, as the latest pnpm
has already made the jump to bundling node-gyp@8
.