k-yle / pdf-to-img

📃📸 Converts PDFs to images in nodejs
https://npm.im/pdf-to-img
MIT License
81 stars 20 forks source link

Throws errors when launching Electron app and when reinstalling #214

Open Konglomneshued opened 1 year ago

Konglomneshued commented 1 year ago

Error when running my Electron app

App threw an error during load

Error: The module '/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release/canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 109. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1810)
    at Module._extensions..node (node:internal/modules/cjs/loader:1205:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1810)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)

A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release/canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 109. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1810)
    at Module._extensions..node (node:internal/modules/cjs/loader:1205:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1810)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)

I've tried deleting my package-lock.json and node_modules folder and re-running npm i

> electron-template@1.0.0 postinstall
> electron-builder install-app-deps

  • electron-builder  version=23.6.0
  • loaded configuration  file=/home/untitled1/VSCodeProjects/batcher/electron-builder.yml
  • rebuilding native dependencies  dependencies=canvas@2.10.2 platform=linux arch=x64
  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path /home/untitled1/VSCodeProjects/batcher/node_modules/canvas
    npm ERR! command failed
    npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary
    npm ERR! Failed to execute '/home/untitled1/.volta/tools/image/node/18.16.0/bin/node /home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v21.4' (1)
    npm ERR! node-pre-gyp info it worked if it ends with ok
    npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
    npm ERR! node-pre-gyp info using node@18.16.0 | linux | x64
    npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.10.2/canvas-v2.10.2-electron-v21.4-linux-glibc-x64.tar.gz
    npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.10.2/canvas-v2.10.2-electron-v21.4-linux-glibc-x64.tar.gz 
    npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.10.2 and electron@21.4.4 (electron-v21.4 ABI, glibc) (falling back to source compile with node-gyp) 
    npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.10.2/canvas-v2.10.2-electron-v21.4-linux-glibc-x64.tar.gz 
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@9.3.1
    npm ERR! gyp info using node@18.16.0 | linux | x64
    npm ERR! gyp info ok 
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@9.3.1
    npm ERR! gyp info using node@18.16.0 | linux | x64
    npm ERR! gyp info find Python using Python version 3.11.3 found at "/usr/bin/python3"
    npm ERR! gyp info spawn /usr/bin/python3
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '/home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    npm ERR! gyp info spawn args   'binding.gyp',
    npm ERR! gyp info spawn args   '-f',
    npm ERR! gyp info spawn args   'make',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/home/untitled1/.electron-gyp/21.4.4/include/node/common.gypi',
    npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
    npm ERR! gyp info spawn args   '-Dvisibility=default',
    npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/untitled1/.electron-gyp/21.4.4',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/untitled1/.electron-gyp/21.4.4/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas',
    npm ERR! gyp info spawn args   '-Dnode_engine=v8',
    npm ERR! gyp info spawn args   '--depth=.',
    npm ERR! gyp info spawn args   '--no-parallel',
    npm ERR! gyp info spawn args   '--generator-output',
    npm ERR! gyp info spawn args   'build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! Package pixman-1 was not found in the pkg-config search path.
    npm ERR! Perhaps you should add the directory containing `pixman-1.pc'
    npm ERR! to the PKG_CONFIG_PATH environment variable
    npm ERR! Package 'pixman-1', required by 'virtual:world', not found
    npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
    npm ERR! gyp ERR! configure error 
    npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:325:16)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
    npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
    npm ERR! gyp ERR! System Linux 6.2.15-300.fc38.x86_64
    npm ERR! gyp ERR! command "/home/untitled1/.volta/tools/image/node/18.16.0/bin/node" "/home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v21.4"
    npm ERR! gyp ERR! cwd /home/untitled1/VSCodeProjects/batcher/node_modules/canvas
    npm ERR! gyp ERR! node -v v18.16.0
    npm ERR! gyp ERR! node-gyp -v v9.3.1
    npm ERR! gyp ERR! not ok 
    npm ERR! node-pre-gyp ERR! build error 
    npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/home/untitled1/.volta/tools/image/node/18.16.0/bin/node /home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/untitled1/VSCodeProjects/batcher/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v21.4' (1)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/untitled1/VSCodeProjects/batcher/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
    npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
    npm ERR! node-pre-gyp ERR! System Linux 6.2.15-300.fc38.x86_64
    npm ERR! node-pre-gyp ERR! command "/home/untitled1/.volta/tools/image/node/18.16.0/bin/node" "/home/untitled1/VSCodeProjects/batcher/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
    npm ERR! node-pre-gyp ERR! cwd /home/untitled1/VSCodeProjects/batcher/node_modules/canvas
    npm ERR! node-pre-gyp ERR! node -v v18.16.0
    npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
    npm ERR! node-pre-gyp ERR! not ok

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/untitled1/.npm/_logs/2023-05-15T02_49_01_414Z-debug-0.log

                    command=/home/untitled1/.volta/tools/image/node/18.16.0/bin/node /home/untitled1/.volta/tools/image/node/18.16.0/lib/node_modules/npm/bin/npm-cli.js rebuild canvas@2.10.2
                    workingDir=
npm ERR! code 1
npm ERR! path /home/untitled1/VSCodeProjects/batcher
npm ERR! command failed
npm ERR! command sh -c electron-builder install-app-deps

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/untitled1/.npm/_logs/2023-05-15T02_47_31_149Z-debug-0.log
k-yle commented 1 year ago

The relevant line is:

npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.10.2 and electron@21.4.4 (electron-v21.4 ABI, glibc) (falling back to source compile with node-gyp) 

It sounds like node-canvas doesn't support your version of electron

Badestrand commented 3 months ago

Also fails to install on my Mac, with Pre-built binaries not installable for canvas@2.11.2 and node@18.19.0.

k-yle commented 2 months ago

@Badestrand your issue seems to be a known limitation, see https://github.com/Automattic/node-canvas/pull/2354