node-libcurl icon indicating copy to clipboard operation
node-libcurl copied to clipboard

Can't build on macos

Open nullbyteptr opened this issue 2 years ago • 2 comments

Getting following error

node-libcurl % npm_config_build_from_source=true npm_config_curl_static_build=true npm_config_curl_include_dirs="$(xcrun --show-sdk-path)/usr/include" yarn add node-libcurl
yarn add v1.22.18
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
warning [email protected]: The engine "git" appears to be invalid.
[4/5] 🔗  Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "tslint@^5.11.0".
warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "tslint@^5.0.0".
warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "tslint@^5.0.0".
warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "typescript@^2.2.0 || ^3.0.0".
warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "tslint@^5.1.0".
warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "typescript@^2.1.0 || ^3.0.0".
warning "tslint-config-airbnb > tslint-consistent-codestyle > @fimbul/[email protected]" has incorrect peer dependency "tslint@^5.0.0".
warning " > [email protected]" has incorrect peer dependency "typedoc@^0.11.1".
[5/5] 🔨  Building fresh packages...
[1/3] ⠠ core-js
[2/3] ⠠ husky
error /Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | x64
node-pre-gyp info build requesting source compile
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.8.2 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nullbyte/Library/Caches/node-gyp/16.11.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/nullbyte/Library/Caches/node-gyp/16.11.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/nullbyte/Library/Caches/node-gyp/16.11.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/node_libcurl/src/node_libcurl.o
  CXX(target) Release/obj.target/node_libcurl/src/Easy.o
  CXX(target) Release/obj.target/node_libcurl/src/Share.o
  CXX(target) Release/obj.target/node_libcurl/src/Multi.o
  CXX(target) Release/obj.target/node_libcurl/src/Curl.o
  CXX(target) Release/obj.target/node_libcurl/src/CurlHttpPost.o
  CXX(target) Release/obj.target/node_libcurl/src/CurlVersionInfo.o
../src/CurlVersionInfo.cc:19:6: warning: unused function 'SetObjPropertyToNullOrValue' [-Wunused-function]
void SetObjPropertyToNullOrValue<v8::Local<v8::Primitive>>(v8::Local<v8::Object> obj,
     ^
1 warning generated.
  CXX(target) Release/obj.target/node_libcurl/src/Http2PushFrameHeaders.o
  SOLINK_MODULE(target) Release/node_libcurl.node
clang: error: no such file or directory: '/usr/lib/libcurl.@libext@'
clang: error: no such file or directory: '@LDFLAGS@'
clang: error: no such file or directory: '@LIBCURL_LIBS@'
make: *** [Release/node_libcurl.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/usr/local/bin/node" "/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/lib/binding/node_libcurl.node" "--module_name=node_libcurl" "--module_path=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
gyp ERR! cwd /Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl
gyp ERR! node -v v16.11.1
gyp ERR! node-gyp -v v9.3.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl --module_path=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
node-pre-gyp ERR! System Darwin 20.6.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl
node-pre-gyp ERR! node -v v16.11.1
node-pre-gyp ERR! node-pre-gyp -v v1.0.10
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/nullbyte/WebstormProjects/libcurlnode/node-libcurl/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl

OS: macos big sur 11.6 Node.js Version: Tried 14/16/18

nullbyteptr avatar Feb 14 '23 16:02 nullbyteptr

There is a problem when compiling with MacOS built-in curl. A temporary workaround is to install curl from brew and use it.

  • brew install curl
  • export PATH=/usr/local/Cellar/curl/7.87.0/bin/:$PATH
  • npm install node-libcurl

rick51231 avatar Feb 26 '23 11:02 rick51231

A potential problem is: the brew-installed curl is bulit with --without-ca-bundle --without-ca-path --with-ca-fallback flags.

Not sure if it has any security issues.

notjaywu avatar Jan 08 '24 08:01 notjaywu

it seems the curl-config file provided with macos has some broken variables: image

one option is using brew's libcurl, which as mentioned above, or building libcurl from source, the build.sh script inside ./scripts/ci/build.sh could be useful in this case.

Here is an example build command that is used to build everything from source:

LATEST_LIBCURL_RELEASE=7.86.0 LIBCURL_RELEASE=7.86.0 PUBLISH_BINARY="true" ./scripts/ci/build.sh

JCMais avatar Feb 13 '24 14:02 JCMais