Unable to install npm package

Operating system

macOS

Joplin version

2.14.1

What issue do you have?

❯ NPM_CONFIG_PREFIX=~/.joplin-bin npm install -g joplin

npm WARN deprecated @types/nanoid@3.0.0: This is a stub types definition. nanoid provides its own type definitions, so you do not need this installed.
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead
npm WARN deprecated domexception@4.0.0: Use your platform's native DOMException instead
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
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 https://github.com/request/request/issues/3142
npm WARN deprecated highlight.js@9.12.0: Version no longer supported. Upgrade to @latest
npm WARN deprecated highlight.js@9.12.0: Version no longer supported. Upgrade to @latest
npm ERR! code 1
npm ERR! path /Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c node install/check
npm ERR! sharp: Detected globally-installed libvips v8.15.2
npm ERR! sharp: Attempting to build from source via node-gyp
npm ERR! sharp: Found node-addon-api
npm ERR! sharp: Found node-gyp version 8.4.1
npm ERR! sharp: See https://sharp.pixelplumbing.com/install#building-from-source
npm ERR!   CC(target) Release/obj.target/nothing/../../node-addon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   TOUCH Release/obj.target/libvips-cpp.stamp
npm ERR!   CXX(target) Release/obj.target/sharp-darwin-arm64/common.o
npm ERR!   CXX(target) Release/obj.target/sharp-darwin-arm64/metadata.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@21.7.1 | darwin | arm64
npm ERR! gyp info chdir src
npm ERR! gyp info find Python using Python version 3.12.2 found at "/opt/homebrew/opt/python@3.12/bin/python3.12"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.12/bin/python3.12
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/ss99569/.joplin-bin/lib/node_modules/joplin/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/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/sharp/src/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/ss99569/Library/Caches/node-gyp/21.7.1/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/ss99569/Library/Caches/node-gyp/21.7.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/ss99569/Library/Caches/node-gyp/21.7.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/sharp/src',
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! <string>:114: SyntaxWarning: invalid escape sequence '\/'
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! ../metadata.cc:233:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
npm ERR!         info.Set("exif", Napi::Buffer<char>::NewOrCopy(env, baton->exif, baton->exifLength, sharp::FreeCallback));
npm ERR!                          ~~~~~~~~~~~~~~~~~~~~^
npm ERR! ../metadata.cc:236:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
npm ERR!         info.Set("icc", Napi::Buffer<char>::NewOrCopy(env, baton->icc, baton->iccLength, sharp::FreeCallback));
npm ERR!                         ~~~~~~~~~~~~~~~~~~~~^
npm ERR! ../metadata.cc:239:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
npm ERR!         info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
npm ERR!                          ~~~~~~~~~~~~~~~~~~~~^
npm ERR! ../metadata.cc:242:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
npm ERR!         info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
npm ERR!                         ~~~~~~~~~~~~~~~~~~~~^
npm ERR! ../metadata.cc:246:31: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
npm ERR!           Napi::Buffer<char>::NewOrCopy(env, baton->tifftagPhotoshop,
npm ERR!           ~~~~~~~~~~~~~~~~~~~~^
npm ERR! 5 errors generated.
npm ERR! make: *** [Release/obj.target/sharp-darwin-arm64/metadata.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.onExit (/Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Darwin 23.4.0
npm ERR! gyp ERR! command "/Users/ss99569/.nvm/versions/node/v21.7.1/bin/node" "/Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/.bin/node-gyp" "rebuild" "--directory=src"
npm ERR! gyp ERR! cwd /Users/ss99569/.joplin-bin/lib/node_modules/joplin/node_modules/sharp/src
npm ERR! gyp ERR! node -v v21.7.1
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/ss99569/.npm/_logs/2024-03-21T03_08_47_648Z-debug-0.log

How can I fix this?

Try node 18

Running export SHARP_IGNORE_GLOBAL_LIBVIPS=1 before NPM_CONFIG_PREFIX=~/.joplin-bin npm install -g joplin may also help.

I didn't wanna downgrade my npm. The sharp ignore flag worked!