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

no member named errors with node-addon-api@^5 #1029

Open
karlhorky opened this issue Apr 6, 2024 · 3 comments · May be fixed by #1049
Open

no member named errors with node-addon-api@^5 #1029

karlhorky opened this issue Apr 6, 2024 · 3 comments · May be fixed by #1049

Comments

@karlhorky
Copy link

karlhorky commented Apr 6, 2024

What went wrong?

Installing [email protected] and [email protected] together causes no member named errors:

{
  "dependencies": {
    "bcrypt": "5.1.1",
    "sharp": "0.33.2"
  }
}

Error logs:

$ pnpm i
 WARN  2 deprecated subdependencies found: [email protected], [email protected]
Packages: +843
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 912, reused 844, downloaded 0, added 24, done
node_modules/.pnpm/[email protected]/node_modules/sharp: Running install script, failed in 5.1s
.../[email protected]/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 [email protected]
│ gyp info using [email protected] | darwin | arm64
│ gyp info chdir src
│ gyp info find Python using Python version 3.12.2 found at "/opt/homebrew/opt/[email protected]/bin/python3.12"
│ gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.12
│ gyp info spawn args [
│ gyp info spawn args '/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.3/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/next-js-example-winter-2024-atvie/node_modules/.pnpm/[email protected]/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.3/dist/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/k/Library/Caches/node-gyp/20.12.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/k/Library/Caches/node-gyp/20.12.1',
│ gyp info spawn args '-Dnode_gyp_dir=/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.3/dist/node_modules/node-gyp',
│ gyp info spawn args '-Dnode_lib_file=/Users/k/Library/Caches/node-gyp/20.12.1/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/Users/k/p/next-js-example-winter-2024-atvie/node_modules/.pnpm/[email protected]/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/../../../../[email protected]/node_modules/node-addon-api/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 i…
│   TOUCH Release/obj.target/libvips-cpp.stamp
│   CXX(target) Release/obj.target/sharp-darwin-arm64/common.o
│   CXX(target) Release/obj.target/sharp-darwin-arm64/metadata.o
│ ../metadata.cc:233:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
│         info.Set("exif", Napi::Buffer<char>::NewOrCopy(env, baton->exif, baton->exifLength, sharp::FreeCallback));
│                          ~~~~~~~~~~~~~~~~~~~~^
│ ../metadata.cc:236:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
│         info.Set("icc", Napi::Buffer<char>::NewOrCopy(env, baton->icc, baton->iccLength, sharp::FreeCallback));
│                         ~~~~~~~~~~~~~~~~~~~~^
│ ../metadata.cc:239:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
│         info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
│                          ~~~~~~~~~~~~~~~~~~~~^
│ ../metadata.cc:242:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
│         info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
│                         ~~~~~~~~~~~~~~~~~~~~^
│ ../metadata.cc:246:31: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
│           Napi::Buffer<char>::NewOrCopy(env, baton->tifftagPhotoshop,
│           ~~~~~~~~~~~~~~~~~~~~^
│ 5 errors generated.
│ make: *** [Release/obj.target/sharp-darwin-arm64/metadata.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.3/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.1/bin/node" "/Users/k/.cache/node/corepack/v1/pnpm/9.0.0-beta.3/dist/node_modules/node-gyp/bin/node-gyp.js" "r…
│ gyp ERR! cwd /Users/k/p/next-js-example-winter-2024-atvie/node_modules/.pnpm/[email protected]/node_modules/sharp/src
│ gyp ERR! node -v v20.12.1
│ gyp ERR! node-gyp -v v10.0.1
│ gyp ERR! not ok 
└─ Failed in 5.1s at /Users/k/p/next-js-example-winter-2024-atvie/node_modules/.pnpm/[email protected]/node_modules/sharp
 ELIFECYCLE  Command failed with exit code 1.

Upon further investigation, there is an older version of node-addon-api (version 5.1.0) in the pnpm lockfile, which appears to be causing the issue (sharp requires node-addon-api@>=7.0.0):

  [email protected]([email protected]):
    dependencies:
      '@mapbox/node-pre-gyp': 1.0.11([email protected])
      node-addon-api: 5.1.0
    transitivePeerDependencies:
      - encoding
      - supports-color

Also visible in the bcrypt package.json:

"node-addon-api": "^5.0.0",

Removing the bcrypt from the package.json appears to make the error go away again.

What did you expect to happen?

[email protected] should be able to coexist with [email protected] without causing sharp build failures

Which version of nodejs and OS?

Node.js: v20.12.1
Package manager: pnpm (latest and v9 beta)
macOS: Sonoma 14.4.1 (23E224)

@karlhorky karlhorky changed the title no member named error with node-addon-api@^5 no member named errors with node-addon-api@^5 Apr 6, 2024
@meenakshishukla21
Copy link

node : v20.10.0
npm: 10.2.3

for this version we are able to install both dependency in windows without getting any failure.

@karlhorky
Copy link
Author

My original reproduction was with pnpm latest (also tried the v9 beta), I've added this detail and the version number above.

@karlhorky
Copy link
Author

Workaround

Use npm Overrides, Yarn Resolutions or pnpm Overrides to force upgrade the version of node-addon-api to the version that you want (also in transitive dependencies), eg:

{
  "pnpm": {
    "overrides": {
      "node-addon-api": "8.1.0"
    }
  }
}

From our first tests, this [email protected] version seems to work with bcrypt. This is also confirmed by other users.

There's an open PR to upgrade here too:

@karlhorky karlhorky linked a pull request Sep 24, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants