NickNaso / ghostscript4js

Ghostscript4JS binds the Ghostscript C API to the Node.JS world.
http://www.nacios.it
Apache License 2.0
68 stars 19 forks source link

Getting error while installing ghostscript4js in MAC PC ( ghostscript4js npm ERR! command failed ) #71

Closed vignesh-selvaraji closed 1 week ago

vignesh-selvaraji commented 1 week ago

prerequisite

  1. Install and Set Up Ghostscript
    • Install Homebrew
    • Install Ghostscript via Homebrew -  brew install ghostscript
    • Set Environment Variable Set the environment variable GS4JS_HOME to '/usr/local/lib'

Error details: While installing the Ghostscript getting the below errors(please refer the screenshot for referance) node version: 20.12.0 electron: 29.1.6

npm install npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. npm WARN deprecated @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported npm WARN deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported npm WARN deprecated boolean@3.2.0: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. npm WARN deprecated eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options. npm ERR! code 1 npm ERR! path /Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o npm ERR! LIBTOOL-STATIC Release/nothing.a npm ERR! CXX(target) Release/obj.target/ghostscript4js/src/ghostscript4js.o npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@10.0.1 npm ERR! gyp info using node@20.12.0 | darwin | x64 npm ERR! gyp info find Python using Python version 3.11.8 found at "/usr/local/bin/python3" npm ERR! gyp info spawn /usr/local/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/local/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 '/Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/sharpdeskssdi/Library/Caches/node-gyp/20.12.0/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=/Users/sharpdeskssdi/Library/Caches/node-gyp/20.12.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/sharpdeskssdi/Library/Caches/node-gyp/20.12.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js', 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! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols) npm ERR! clang: error: no such file or directory: 'Conversion/PDF' npm ERR! clang: error: no such file or directory: 'Conversion/node_modules/node-addon-api' npm ERR! make: *** [Release/obj.target/ghostscript4js/src/ghostscript4js.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: make failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23) npm ERR! gyp ERR! System Darwin 23.3.0 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd /Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js npm ERR! gyp ERR! node -v v20.12.0 npm ERR! gyp ERR! node-gyp -v v10.0.1 npm ERR! gyp ERR! not ok 5

Could someone help me resolve this?

NickNaso commented 1 week ago

Hi @vignesh-selvaraji, could you try to install

xcode-select --install
NickNaso commented 1 week ago

Hi @vignesh-selvaraji, did you solve the problem?

vignesh-selvaraji commented 1 week ago

Hi @NickNaso

No, I am still facing the same issue after installing 'xcode-select --install'.

I'm able to run 'npm install' without having 'ghostscript4js': '^3.2.3' in the package.json. However, when 'ghostscript4js': '^3.2.3' is added, I encounter the following errors again. Can you help me resolve this issue?

error details: npm install ghostscript4js@3.2.3 npm ERR! code 1 npm ERR! path /Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o npm ERR! LIBTOOL-STATIC Release/nothing.a npm ERR! CXX(target) Release/obj.target/ghostscript4js/src/ghostscript4js.o npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@10.0.1 npm ERR! gyp info using node@20.12.0 | darwin | x64 npm ERR! gyp info find Python using Python version 3.11.8 found at "/usr/local/bin/python3" npm ERR! gyp info spawn /usr/local/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/local/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 '/Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/sharpdeskssdi/Library/Caches/node-gyp/20.12.0/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=/Users/sharpdeskssdi/Library/Caches/node-gyp/20.12.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/sharpdeskssdi/Library/Caches/node-gyp/20.12.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js', 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! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols) npm ERR! clang: error: no such file or directory: 'Conversion/PDF' npm ERR! clang: error: no such file or directory: 'Conversion/node_modules/node-addon-api' npm ERR! make: *** [Release/obj.target/ghostscript4js/src/ghostscript4js.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: make failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23) npm ERR! gyp ERR! System Darwin 23.3.0 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd /Users/sharpdeskssdi/Desktop/PDF Conversion/PDF Conversion/node_modules/ghostscript4js npm ERR! gyp ERR! node -v v20.12.0 npm ERR! gyp ERR! node-gyp -v v10.0.1 npm ERR! gyp ERR! not ok

NickNaso commented 1 week ago

Is your code public? Or could you provide a repo with reproducible error?

vignesh-selvaraji commented 1 week ago

@NickNaso Please access my code in the below repo

https://github.com/vignesh-selvaraji/PDF-Conversion-1

NickNaso commented 1 week ago

@NickNaso Please access my code in the below repo

https://github.com/vignesh-selvaraji/PDF-Conversion-1

I cannot access to the repo maybe I you need to give me the perimssion.

vignesh-selvaraji commented 1 week ago

I cannot access to the repo maybe I you need to give me the perimssion.

@NickNaso I will share today.

NickNaso commented 1 week ago

Hi @vignesh-selvaraji, in the new versions of HomeBrew when you install a library like gostscript it will not be linked to /usr/local/lib but it will be in /opt/homebrew/bin/gs. To avoid your error you should not set the environment variable GS4JS_HOME and the installation script will try to find the right path for you https://github.com/NickNaso/ghostscript4js/blob/master/binding.gyp#L96 executing the script in https://github.com/NickNaso/ghostscript4js/blob/master/macOS-lib-path-finder.js Let me know if it worked ofr you.

vignesh-selvaraji commented 1 week ago

Is your code public? Or could you provide a repo with reproducible error?

Hi @NickNaso Could you please check if it's working for you? Before checking, please rename the folder from vscode to .vscode and follow the steps in the README. The above comment i'm checking

https://github.com/vignesh-selvaraji/PDFA-Conversion

NickNaso commented 1 week ago

Hi @vignesh-selvaraji, I cloned the repo and then I tried to install the packages with npm install and the installation went good.

vignesh-selvaraji commented 1 week ago

HI @NickNaso I can able to install the npm by removing the GS4JS_HOME environment variable. thanks