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

npm i node-gd and error #91

Closed
MrMaxorz opened this issue Aug 26, 2022 · 12 comments
Closed

npm i node-gd and error #91

MrMaxorz opened this issue Aug 26, 2022 · 12 comments

Comments

@MrMaxorz
Copy link

When I do npm i node-gd I found this error:

npm ERR! code 1
npm ERR! path /Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@5.1.1
npm ERR! gyp info using node@16.16.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.13 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
npm ERR! (node:15733) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use node --trace-deprecation ... to show where the warning was created)
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/Maxorz/Works/Longdo/thaimap-services/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/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Maxorz/Library/Caches/node-gyp/16.16.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/Maxorz/Library/Caches/node-gyp/16.16.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/Maxorz/Library/Caches/node-gyp/16.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd',
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! xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
npm ERR! Use sudo xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools, or use xcode-select --install to install the standalone command line developer tools.
npm ERR! See man xcode-select for more details.
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onExit (/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.5.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node@16/16.16.0/bin/node" "/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v5.1.1
npm ERR! gyp ERR! not ok

How can I fix this issue? I already install brew install pkg-config gd

System Version: macOS 12.4 (21F79)
Macbook pro M1

@y-a-v-a
Copy link
Owner

y-a-v-a commented Aug 26, 2022

Hi,
Isn't this message the solution?

npm ERR! Use sudo xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools, or use xcode-select --install to install the standalone command line developer tools.

Cheers Vincent

@MrMaxorz
Copy link
Author

MrMaxorz commented Aug 26, 2022

Thanks for response.

After I fix Xcode now I found this error:

npm ERR! code 1
npm ERR! path /Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR! LIBTOOL-STATIC Release/nothing.a
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@5.1.1
npm ERR! gyp info using node@16.16.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! (node:4115) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use node --trace-deprecation ... to show where the warning was created)
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/Maxorz/Works/Longdo/thaimap-services/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/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Maxorz/Library/Caches/node-gyp/16.16.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/Maxorz/Library/Caches/node-gyp/16.16.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/Maxorz/Library/Caches/node-gyp/16.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd',
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! env: python: No such file or directory
npm ERR! make: *** [Release/nothing.a] Error 127
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.onExit (/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.5.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node@16/16.16.0/bin/node" "/Users/Maxorz/Works/Longdo/thaimap-services/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/Maxorz/Works/Longdo/thaimap-services/node_modules/node-gd
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v5.1.1
npm ERR! gyp ERR! not ok

@MrMaxorz
Copy link
Author

no luck with this issue 😭

$npm install node-gd
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see request/request#3142
npm ERR! code 1
npm ERR! path /Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gd
npm ERR! command failed
npm ERR! command sh /var/folders/pp/kfsc9n0j3b9221jz5znvsgt00000gn/T/install-5e70ca68.sh
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR! LIBTOOL-STATIC Release/nothing.a
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@5.1.1
npm ERR! gyp info using node@16.17.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! (node:38918) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use node --trace-deprecation ... to show where the warning was created)
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/Maxorz/Works/Longdo/thaimap-snippet/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/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gd/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Maxorz/Library/Caches/node-gyp/16.17.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/Maxorz/Library/Caches/node-gyp/16.17.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/Maxorz/Library/Caches/node-gyp/16.17.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gd',
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! env: python: No such file or directory
npm ERR! make: *** [Release/nothing.a] Error 127
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.onExit (/Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.5.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node@16/16.17.0/bin/node" "/Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/Maxorz/Works/Longdo/thaimap-snippet/node_modules/node-gd
npm ERR! gyp ERR! node -v v16.17.0
npm ERR! gyp ERR! node-gyp -v v5.1.1
npm ERR! gyp ERR! not ok

I try for new install brew and npm but it's not working.
so sad 😢

These are my reproduction steps:

  1. Reinstall brew
  2. brew install node@16
  3. brew install pkg-config gd
  4. npm install node-gd
  5. then the error log shows

@MrMaxorz
Copy link
Author

try to run this:

$npm test

> node-gd@3.0.0 pretest
> node-gyp build -j max

gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.17.0 | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 8 ]
  CXX(target) Release/obj.target/node_gd/src/addon.o
In file included from ../src/addon.cc:19:
../src/node_gd.h:22:10: fatal error: 'gd.h' file not found
#include <gd.h>
         ^~~~~~
1 error generated.
make: *** [Release/obj.target/node_gd/src/addon.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/Maxorz/Downloads/node-gd-master/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.5.0
gyp ERR! command "/opt/homebrew/Cellar/node@16/16.17.0/bin/node" "/Users/Maxorz/Downloads/node-gd-master/node_modules/.bin/node-gyp" "build" "-j" "max"
gyp ERR! cwd /Users/Maxorz/Downloads/node-gd-master
gyp ERR! node -v v16.17.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok 

@MrMaxorz
Copy link
Author

may be this issue found only in arm64

@vitorbertolucci
Copy link
Contributor

vitorbertolucci commented Sep 8, 2022

You're correct, this is an ARM only issue and I've been having it for a while now. It does not compile on neither mac M1 nor M2.

@vitorbertolucci
Copy link
Contributor

vitorbertolucci commented Sep 8, 2022

I managed to make it work on my Macbook M2.

There are two problems:

1 - node-gd requires an older version of Python, so you need to install Python 2.7.18 from https://www.python.org/downloads/release/python-2718/

2 - node-gyp is cannot locate the gd files (gd.h, gd_io.h and so on) on the directories /opt/homebrew/include/ and /otp/homebrew/lib/, since it only looks for them on /usr/local/*. I've tried creating a symlink, but since the files under those directories are symlinks themselves I ended up having the Too many levels of symlinks error.

So I decided to simply copy the required files to /usr/local and it worked.

sudo cp -R /opt/homebrew/include/* /usr/local/include
sudo cp -R /otp/homebrew/lib/* /usr/local/lib

I'm sure there must be a more elegant way to solve this, but at least I'm no longer stuck with this issue.

@hknguyenvu
Copy link

hknguyenvu commented May 24, 2023

I found the solution. You must set the environment variable

CPLUS_INCLUDE_PATH=/opt/homebrew/include
LD_LIBRARY_PATH=/opt/homebrew/lib
LIBRARY_PATH=/opt/homebrew/lib

Reference: Automattic/node-canvas#1733

@vitorbertolucci
Copy link
Contributor

I found the solution. You must set the environment variable

CPLUS_INCLUDE_PATH=/opt/homebrew/include LD_LIBRARY_PATH=/opt/homebrew/lib LIBRARY_PATH=/opt/homebrew/lib

Reference: Automattic/node-canvas#1733

I ended up forking the project with a fix so I don't have to keep fixing it every time, you can find it here: https://github.com/vitorbertolucci/node-gd

It's also published on npm at https://www.npmjs.com/package/@vitorbertolucci/node-gd

@hknguyenvu
Copy link

Thanks. However I think I will stick with the original ^^

@y-a-v-a
Copy link
Owner

y-a-v-a commented Jun 5, 2023

Just release v3.0.0 that might fix the M1 and M2 issues.

@y-a-v-a
Copy link
Owner

y-a-v-a commented Jun 5, 2023

For now I'd like to close this ticket, if one has any findings with regard to M1 and/or M2, please open a new ticket so I can take a look. Thanks in advance.

@y-a-v-a y-a-v-a closed this as completed Jun 5, 2023
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

4 participants