Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.15k stars 1.17k forks source link

It seems pre-built binary downloading does not follow proxy environment variables #2419

Open marjune163 opened 2 months ago

marjune163 commented 2 months ago

Issue or Feature

It seems pre-built binary downloading does not follow proxy environment variables. I have difficulty accessing npm registry and github directly. When I run npm install, I actually run https_proxy=MY_PROXY_ADDRESS npm install. This works for downloading regular npm package via proxy. But when installing node-canvas, it stucks at downloading prebuilt binary. Seems it always try to connect github directly without proxy.

Steps to Reproduce

$ https_proxy=XXXXXXXXXXXX npm install --verbose
npm verbose cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@10.8.1
npm info using node@v20.16.0
npm verbose title npm install
npm verbose argv "install" "--loglevel" "verbose"
npm verbose logfile logs-max:10 dir:/home/myname/.npm/_logs/2024-08-21T12_48_40_765Z-
npm verbose logfile /home/myname/.npm/_logs/2024-08-21T12_48_40_765Z-debug-0.log
npm verbose reify failed optional dependency /work/myproject/node_modules/playwright/node_modules/fsevents
npm verbose reify failed optional dependency /work/myproject/node_modules/fsevents
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-win32-x64-msvc
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-win32-ia32-msvc
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-win32-arm64-msvc
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-linux-arm64-musl
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-linux-arm64-gnu
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-linux-arm-gnueabihf
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-darwin-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@swc/core-darwin-arm64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/win32-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/win32-ia32
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/win32-arm64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/sunos-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/openbsd-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/netbsd-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-s390x
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-riscv64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-ppc64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-mips64el
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-loong64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-ia32
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-arm64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/linux-arm
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/freebsd-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/freebsd-arm64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/darwin-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/darwin-arm64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/android-x64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/android-arm64
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/android-arm
npm verbose reify failed optional dependency /work/myproject/node_modules/@esbuild/aix-ppc64
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 5711ms
npm warn deprecated npmlog@5.0.1: This package is no longer supported.
npm warn deprecated are-we-there-yet@2.0.0: This package is no longer supported.
npm http fetch GET 200 https://registry.npmjs.org/ws 6219ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/terser 6335ms (cache revalidated)
npm warn deprecated gauge@3.0.2: This package is no longer supported.
npm http fetch GET 200 https://registry.npmjs.org/tar-stream 6444ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/tailwindcss 6541ms (cache revalidated)
...
...
...
npm info run canvas@2.11.2 install node_modules/canvas node-pre-gyp install --fallback-to-build --update-binary
npm http fetch GET 200 https://registry.npmjs.org/postal.request-response 722ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/css-select 103ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/socket.io-client 111ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/react-scripts 127ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@storybook%2fcli 312ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/svgo 115ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/react-app-rewired 288ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@storybook%2fpreset-create-react-app 1586ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/storybook 225ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@svgr%2fplugin-svgo 145ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@svgr%2fwebpack 130ms (cache revalidated)

Stucked here. When press Ctrl+C, shows:

npm info run canvas@2.11.2 install { code: null, signal: 'SIGINT' }
npm verbose stack Error: command failed
npm verbose stack     at promiseSpawn (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:22:22)
npm verbose stack     at spawnWithShell (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:124:10)
npm verbose stack     at promiseSpawn (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:12:12)
npm verbose stack     at runScriptPkg (/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js:77:13)
npm verbose stack     at runScript (/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script.js:9:12)
npm verbose stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:329:17
npm verbose stack     at run (/usr/local/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:67:22)
npm verbose stack     at /usr/local/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:84:9
npm verbose stack     at new Promise (<anonymous>)
npm verbose stack     at callLimit (/usr/local/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:35:69)
npm verbose pkgid canvas@2.11.2
npm error path /work/myproject/node_modules/canvas
npm error command failed
npm error signal SIGINT
npm error command sh -c node-pre-gyp install --fallback-to-build --update-binary
npm error node-pre-gyp info it worked if it ends with ok
npm error node-pre-gyp verb cli [
npm error node-pre-gyp verb cli   '/usr/local/bin/node',
npm error node-pre-gyp verb cli   '/work/myproject/node_modules/.bin/node-pre-gyp',
npm error node-pre-gyp verb cli   'install',
npm error node-pre-gyp verb cli   '--fallback-to-build',
npm error node-pre-gyp verb cli   '--update-binary'
npm error node-pre-gyp verb cli ]
npm error node-pre-gyp info using node-pre-gyp@1.0.11
npm error node-pre-gyp info using node@20.16.0 | linux | x64
npm error node-pre-gyp verb command install []
npm error node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v115-linux-glibc-x64.tar.gz
npm error node-pre-gyp info install unpacking Release/
npm error node-pre-gyp info install unpacking Release/libfontconfig.so.1
npm verbose cwd /work/myproject
npm verbose os Linux 6.1.0-22-amd64
npm verbose node v20.16.0
npm verbose npm  v10.8.1
npm verbose exit 1
npm verbose code 1
npm error A complete log of this run can be found in: /home/myname/.npm/_logs/2024-08-21T12_52_58_532Z-debug-0.log

Your Environment

$ node --version
v20.16.0
$ npm --version
10.8.1
exige81 commented 2 days ago

You can configure node-pre-gyp to use a mirror that you have access to using the --canvas_binary_host_mirror flag. See #1771 for some more info