Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js 17 not supported (Failed to install node-gyp) #8

Closed
DCSBL opened this issue Nov 11, 2021 · 2 comments
Closed

Node.js 17 not supported (Failed to install node-gyp) #8

DCSBL opened this issue Nov 11, 2021 · 2 comments

Comments

@DCSBL
Copy link

DCSBL commented Nov 11, 2021

Just to have this on record for other users with the same problem: Running npm install with Node.js 17 will fail with an error that tries to mention that node-gyp cannot be installed:

`npm install` error, click to open
RUN npm install:                                                                                                                                                                                                     
#10 7.958 npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142              
#10 9.397 npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142                                                                                                 
#10 11.03 npm WARN deprecated har-validator@5.1.5: this library is no longer supported                                                                                                                                        
#10 13.93 npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.                                                                                           
#10 19.19 npm WARN deprecated parcel-bundler@1.12.5: Parcel v1 is no longer maintained. Please migrate to v2, which is published under the 'parcel' package. See https://v2.parceljs.org/getting-started/migration for details.
#10 21.26 npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
#10 29.26 npm notice 
#10 29.26 npm notice New patch version of npm available! 8.1.2 -> 8.1.3
#10 29.26 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.1.3>
#10 29.26 npm notice Run `npm install -g npm@8.1.3` to update!
#10 29.27 npm notice 
#10 29.27 npm ERR! code 1
#10 29.27 npm ERR! path /usr/src/app/node_modules/canvas
#10 29.27 npm ERR! command failed
#10 29.27 npm ERR! command sh -c node-pre-gyp install --fallback-to-build
#10 29.27 npm ERR! make: Entering directory '/usr/src/app/node_modules/canvas/build'
#10 29.27 npm ERR!   SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
#10 29.27 npm ERR!   COPY Release/canvas-postbuild.node
#10 29.27 npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/Backend.o
#10 29.27 npm ERR! make: Leaving directory '/usr/src/app/node_modules/canvas/build'
#10 29.27 npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
#10 29.27 npm ERR! node-pre-gyp info it worked if it ends with ok
#10 29.27 npm ERR! node-pre-gyp info using node-pre-gyp@0.15.0
#10 29.27 npm ERR! node-pre-gyp info using node@17.1.0 | linux | x64
#10 29.27 npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download 
#10 29.27 npm ERR! node-pre-gyp info check checked for "/usr/src/app/node_modules/canvas/build/Release/canvas.node" (not found)
#10 29.27 npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz
#10 29.27 npm ERR! node-pre-gyp http 404 https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz
#10 29.27 npm ERR! node-pre-gyp WARN Tried to download(404): https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz 
#10 29.27 npm ERR! node-pre-gyp WARN Pre-built binaries not found for canvas@2.7.0 and node@17.1.0 (node-v102 ABI, glibc) (falling back to source compile with node-gyp) 
#10 29.27 npm ERR! node-pre-gyp http 404 status code downloading tarball https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz 
#10 29.27 npm ERR! gyp info it worked if it ends with ok
#10 29.27 npm ERR! gyp info using node-gyp@8.3.0
#10 29.27 npm ERR! gyp info using node@17.1.0 | linux | x64
#10 29.27 npm ERR! gyp info ok 
#10 29.27 npm ERR! gyp info it worked if it ends with ok
#10 29.27 npm ERR! gyp info using node-gyp@8.3.0
#10 29.27 npm ERR! gyp info using node@17.1.0 | linux | x64
#10 29.28 npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
#10 29.28 npm ERR! gyp http GET https://nodejs.org/download/release/v17.1.0/node-v17.1.0-headers.tar.gz
#10 29.28 npm ERR! gyp http 200 https://nodejs.org/download/release/v17.1.0/node-v17.1.0-headers.tar.gz
#10 29.28 npm ERR! gyp http GET https://nodejs.org/download/release/v17.1.0/SHASUMS256.txt
#10 29.28 npm ERR! gyp http 200 https://nodejs.org/download/release/v17.1.0/SHASUMS256.txt
#10 29.28 npm ERR! gyp info spawn /usr/bin/python3
#10 29.28 npm ERR! gyp info spawn args [
#10 29.28 npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
#10 29.28 npm ERR! gyp info spawn args   'binding.gyp',
#10 29.28 npm ERR! gyp info spawn args   '-f',
#10 29.28 npm ERR! gyp info spawn args   'make',
#10 29.28 npm ERR! gyp info spawn args   '-I',
#10 29.28 npm ERR! gyp info spawn args   '/usr/src/app/node_modules/canvas/build/config.gypi',
#10 29.28 npm ERR! gyp info spawn args   '-I',
#10 29.28 npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
#10 29.28 npm ERR! gyp info spawn args   '-I',
#10 29.28 npm ERR! gyp info spawn args   '/root/.cache/node-gyp/17.1.0/include/node/common.gypi',
#10 29.28 npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
#10 29.28 npm ERR! gyp info spawn args   '-Dvisibility=default',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/17.1.0',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/17.1.0/<(target_arch)/node.lib',
#10 29.28 npm ERR! gyp info spawn args   '-Dmodule_root_dir=/usr/src/app/node_modules/canvas',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_engine=v8',
#10 29.28 npm ERR! gyp info spawn args   '--depth=.',
#10 29.28 npm ERR! gyp info spawn args   '--no-parallel',
#10 29.28 npm ERR! gyp info spawn args   '--generator-output',
#10 29.28 npm ERR! gyp info spawn args   'build',
#10 29.28 npm ERR! gyp info spawn args   '-Goutput_dir=.'
#10 29.28 npm ERR! gyp info spawn args ]
#10 29.28 npm ERR! gyp info ok 
#10 29.28 npm ERR! gyp info it worked if it ends with ok
#10 29.28 npm ERR! gyp info using node-gyp@8.3.0
#10 29.28 npm ERR! gyp info using node@17.1.0 | linux | x64
#10 29.28 npm ERR! gyp info spawn make
#10 29.28 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
#10 29.28 npm ERR! In file included from ../../nan/nan.h:2884,
#10 29.28 npm ERR!                  from ../src/backend/Backend.h:6,
#10 29.28 npm ERR!                  from ../src/backend/Backend.cc:1:
#10 29.28 npm ERR! ../../nan/nan_typedarray_contents.h: In constructor 'Nan::TypedArrayContents<T>::TypedArrayContents(v8::Local<v8::Value>)':
#10 29.28 npm ERR! ../../nan/nan_typedarray_contents.h:34:43: error: 'class v8::ArrayBuffer' has no member named 'GetContents'
#10 29.28 npm ERR!    34 |       data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
#10 29.28 npm ERR!       |                                           ^~~~~~~~~~~
#10 29.28 npm ERR! make: *** [canvas.target.mk:162: Release/obj.target/canvas/src/backend/Backend.o] Error 1
#10 29.28 npm ERR! gyp ERR! build error 
#10 29.28 npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
#10 29.28 npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
#10 29.28 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
#10 29.28 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
#10 29.28 npm ERR! gyp ERR! System Linux 5.10.25-linuxkit
#10 29.28 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/src/app/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/src/app/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v102"
#10 29.28 npm ERR! gyp ERR! cwd /usr/src/app/node_modules/canvas
#10 29.28 npm ERR! gyp ERR! node -v v17.1.0
#10 29.28 npm ERR! gyp ERR! node-gyp -v v8.3.0
#10 29.28 npm ERR! gyp ERR! not ok 
#10 29.28 npm ERR! node-pre-gyp ERR! build error 
#10 29.28 npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/src/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1062:16)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
#10 29.28 npm ERR! node-pre-gyp ERR! System Linux 5.10.25-linuxkit
#10 29.28 npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/src/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#10 29.28 npm ERR! node-pre-gyp ERR! cwd /usr/src/app/node_modules/canvas
#10 29.28 npm ERR! node-pre-gyp ERR! node -v v17.1.0
#10 29.28 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.15.0
#10 29.28 npm ERR! node-pre-gyp ERR! not ok
#10 29.32 
#10 29.32 npm ERR! A complete log of this run can be found in:
#10 29.32 npm ERR!     /root/.npm/_logs/2021-11-11T09_11_17_325Z-debug.log

Installation an usage with Node.js 16 works without any issue, and because V17 is not indicated as 'the best to use', I think there is no issue here. This is just to help others who have V17 installed and to see if we can find a solution somewhere in the future.

FYI, I used this Dockerfile to build:

FROM node:17
# Change above to 'FROM node:16' to get this to work

WORKDIR /usr/src/app
RUN apt-get update
RUN apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

COPY package*.json ./

RUN npm install
RUN npm install -g typescript

COPY . .
RUN tsc --build

# Test to see if script runs
CMD [ "node", "lv_img_conv.js", "-h"]
@embeddedt
Copy link
Member

Thanks for reporting this, and for the Dockerfile. That was very helpful for reproducing quickly instead of having to install and configure Node 17 first.

The issue is caused by one of the dependencies; I've added a workaround that seems to fix it for now.

@DCSBL
Copy link
Author

DCSBL commented Nov 11, 2021

Verified! Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants