Skip to content

Upgrade (or remove) node-addon-api? #47

Description

@karlhorky

Hey @pyramation @benasher44, hope you're well!

The node-addon-api@^1.6.3 dependency is pretty ancient by now:

https://github.com/launchql/libpg-query-node/blob/badd4c85da02e8a7badfb050632e7d8010e8ec73/package.json#L30-L34

The current version is node-addon-api@8.0.0 (released 5 Mar 2024)

The old version of node-addon-api can cause weird conflicts - eg. running pnpm install on a project that has both libpg-query and sharp leads to this confusing error (../common.cc:12:10: fatal error: 'napi.h' file not found) in the sharp build:

➜  preflight-test-project-next-js-passing git:(main) ✗ pnpm i
Packages: +638
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 707, reused 622, downloaded 17, added 638, done
node_modules/.pnpm/sharp@0.33.3/node_modules/sharp: Running install script, failed in 4.6s
.../sharp@0.33.3/node_modules/sharp install$ node install/check
│ sharp: Detected globally-installed libvips v8.15.2
│ sharp: Attempting to build from source via node-gyp
│ sharp: Found node-addon-api
│ sharp: Found node-gyp version 10.1.0
│ sharp: See https://sharp.pixelplumbing.com/install#building-from-source
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@10.0.1
│ gyp info using node@20.12.0 | darwin | arm64
│ gyp info chdir src
│ gyp info find Python using Python version 3.12.2 found at "/opt/homebrew/opt/python@3.12/bin/python3.12"
│ gyp info spawn /opt/homebrew/opt/python@3.12/bin/python3.12
│ gyp info spawn args [
│ gyp info spawn args '/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.1/dist/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/k/p/preflight-test-project-next-js-passing/node_modules/.pnpm/sharp@0.33.3/node_modules/sharp/src/build/config.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.1/dist/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/k/Library/Caches/node-gyp/20.12.0/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/k/Library/Caches/node-gyp/20.12.0',
│ gyp info spawn args '-Dnode_gyp_dir=/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.1/dist/node_modules/node-gyp',
│ gyp info spawn args '-Dnode_lib_file=/Users/k/Library/Caches/node-gyp/20.12.0/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/Users/k/p/preflight-test-project-next-js-passing/node_modules/.pnpm/sharp@0.33.3/node_modules/sharp/src',
│ 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 ]
│ <string>:114: SyntaxWarning: invalid escape sequence '\/'
│ gyp info spawn make
│ gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
│   CC(target) Release/obj.target/nothing/../../../../node-addon-api@1.7.2/node_modules/node-addon-api/src/nothing.o
│   LIBTOOL-STATIC Release/nothing.a
│ warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in t…
│   TOUCH Release/obj.target/libvips-cpp.stamp
│   CXX(target) Release/obj.target/sharp-darwin-arm64/common.o
│ ../common.cc:12:10: fatal error: 'napi.h' file not found
│ #include <napi.h>
│          ^~~~~~~~
│ 1 error generated.
│ make: *** [Release/obj.target/sharp-darwin-arm64/common.o] Error 1
│ gyp ERR! build error
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack at ChildProcess.<anonymous> (/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.1/dist/node_modules/node-gyp/lib/build.js:209:23)
│ gyp ERR! System Darwin 23.4.0
│ gyp ERR! command "/opt/homebrew/Cellar/node@20/20.12.0/bin/node" "/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.1/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--directory=src"
│ gyp ERR! cwd /Users/k/p/preflight-test-project-next-js-passing/node_modules/.pnpm/sharp@0.33.3/node_modules/sharp/src
│ gyp ERR! node -v v20.12.0
│ gyp ERR! node-gyp -v v10.0.1
│ gyp ERR! not ok
└─ Failed in 4.6s at /Users/k/p/preflight-test-project-next-js-passing/node_modules/.pnpm/sharp@0.33.3/node_modules/sharp
node_modules/.pnpm/libpg-query@16.1.0_encoding@0.1.13/node_modules/libpg-query: Running install script...
 ELIFECYCLE  Command failed with exit code 1.

Removing libpg-query and running pnpm install resolves the issue with building sharp.

History

node-addon-api was introduced in a commit by @ethanresnick in July 2019:

Activity

  1. karlhorky commented on Apr 6, 2024

    @karlhorky
    ContributorAuthor

    Seems like node-addon-api was updated to ^7.0.0 recently in @gregnr's PR:

    Looks like this PR was merged and published, but it appears from the commit history that it was then reverted

    Edit 1: it was merged into a different branch than the main branch.

    Seems like this is the new PR for WASM by @pyramation , which also upgrades to node-addon-api@^7.0.0:

    Edit 2: WebAssembly support was merged here:

  2. gregnr commented on Apr 6, 2024

    @gregnr
    Contributor

    Don't think it was reverted, my branch was just merged into a wasm-feature branch instead of latest so that it could be tested before a final merge (#48). IIRC we were just waiting on pre-gyp binaries to be uploaded for that branch in order to test everything together. But other than that it should be good to merge.

  3. pyramation commented on May 1, 2024

    @pyramation
    Collaborator

    We're upgrading this hopefully today! Stay tuned!

  4. karlhorky commented on May 15, 2024

    @karlhorky
    ContributorAuthor

    Thanks for the libpg-query@16.2.0 release @pyramation ! 🙌

    I can see that node-addon-api has been upgraded to node-addon-api@^7.0.0 (still not the newest at 8.0.0, but it's probably more compatible).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions