lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.39k stars 1.3k forks source link

Unable to install in Termux #1889

Closed rcrx closed 5 years ago

rcrx commented 5 years ago

Here's the terminal output:

$ npm install --unsafe-perm sharp

> sharp@0.23.1 install /data/data/com.termux/files/home/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-android-armv7.tar.gz
/data/data/com.termux/files/home/node_modules/sharp/install/libvips.js:85
          throw new Error(`Status ${response.statusCode}`);
          ^

Error: Status 404
    at /data/data/com.termux/files/home/node_modules/sharp/install/libvips.js:85:17
    at f (/data/data/com.termux/files/home/node_modules/once/once.js:25:25)
    at ClientRequest.<anonymous> (/data/data/com.termux/files/home/node_modules/simple-get/index.js:63:5)
    at Object.onceWrapper (events.js:299:26)
    at ClientRequest.emit (events.js:209:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:583:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:115:17)
    at TLSSocket.socketOnData (_http_client.js:456:22)
    at TLSSocket.emit (events.js:209:13)
    at addChunk (_stream_readable.js:305:12)
make: Entering directory '/data/data/com.termux/files/home/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
warning: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Wunknown-warning-option]
../src/common.cc:25:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [sharp.target.mk:127: Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/data/data/com.termux/files/home/node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:196:23)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 3.18.22
gyp ERR! command "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /data/data/com.termux/files/home/node_modules/sharp
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/data/data/com.termux/files/home/package.json'
npm WARN home No description
npm WARN home No repository field.
npm WARN home No README data
npm WARN home No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.23.1 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.23.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2019-09-26T17_47_57_782Z-debug.log
$

Any suggestions of how to resolve this would be appreciated.

lovell commented 5 years ago

Does forcing the platform to be Linux rather than Android help?

npm install --platform=linux sharp
rcrx commented 5 years ago

All there was to it.

rishabhrpg commented 3 years ago

Does forcing the platform to be Linux rather than Android help?

npm install --platform=linux sharp

This let me install node_modules but when I'm trying to execute its checking for the platform and throwing an error due to platform mismatch

/root/devdas/node_modules/venom-bot/node_modules/sharp/lib/libvips.js:62
      throw new Error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the '${currentPlatformId}' platform.`);
      ^

Error: 'linux-arm64v8' binaries cannot be used on the 'android-arm64v8' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'android-arm64v8' platform.
    at Object.hasVendoredLibvips (/root/devdas/node_modules/venom-bot/node_modules/sharp/lib/libvips.js:62:13)
    at Object.<anonymous> (/root/devdas/node_modules/venom-bot/node_modules/sharp/lib/constructor.js:7:22)
UdjinStolboviy commented 2 years ago

Hello ! Please try this option add package pkg install libvips npm i

UdjinStolboviy commented 2 years ago

Also you can try to install ubuntu 20 and install v packages

  1. Go to termux and run this command "apt upgrade"
  2. install the application on android from the play store 'Andronix' 3 copy the command to install the termux operating system from this application 4 wait for installation If something did not work out for you, you can find a video on how to do it
weskerty commented 5 months ago

Does forcing the platform to be Linux rather than Android help?

npm install --platform=linux sharp

I get an even bigger error with that command.

npm error code 1 npm error git dep preparation failed npm error command /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/usr/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/data/data/com.termux/files/home/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm error > sharp@0.30.7 install npm error > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) npm error npm error sharp: Detected globally-installed libvips v8.15.2 npm error sharp: Building from source via node-gyp npm error npm warn using --force Recommended protections disabled. npm error npm warn deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. npm error npm warn deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin. npm error npm warn deprecated domexception@2.0.1: Use your platform's native DOMException instead npm error npm warn deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead npm error npm warn deprecated vm2@3.9.19: The library contains critical security issues and should not be used for production! The maintenance of the project has been discontinued. Consider migrating your code to isolated-vm. npm error npm warn deprecated phin@2.9.3: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. npm error npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. npm error npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported npm error npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported npm error npm warn deprecated @humanwhocodes/config-array@0.11.10: Use @eslint/config-array instead npm error npm warn deprecated @humanwhocodes/object-schema@1.2.1: Use @eslint/object-schema instead npm error 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 error gyp info it worked if it ends with ok npm error gyp info using node-gyp@10.1.0 npm error gyp info using node@22.2.0 | android | arm64 npm error gyp info find Python using Python version 3.11.9 found at "/data/data/com.termux/files/usr/bin/python3" npm error gyp http GET https://nodejs.org/download/release/v22.2.0/node-v22.2.0-headers.tar.gz npm error gyp http 200 https://nodejs.org/download/release/v22.2.0/node-v22.2.0-headers.tar.gz npm error gyp http GET https://nodejs.org/download/release/v22.2.0/SHASUMS256.txt npm error gyp http 200 https://nodejs.org/download/release/v22.2.0/SHASUMS256.txt npm error gyp info spawn /data/data/com.termux/files/usr/bin/python3 npm error gyp info spawn args [ npm error gyp info spawn args '/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm error gyp info spawn args 'binding.gyp', npm error gyp info spawn args '-f', npm error gyp info spawn args 'make', npm error gyp info spawn args '-I', npm error gyp info spawn args '/data/data/com.termux/files/home/.npm/_cacache/tmp/git-clonePQM76s6fE6PX/node_modules/sharp/build/config.gypi', npm error gyp info spawn args '-I', npm error gyp info spawn args '/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm error gyp info spawn args '-I', npm error gyp info spawn args '/data/data/com.termux/files/home/.cache/node-gyp/22.2.0/include/node/common.gypi', npm error gyp info spawn args '-Dlibrary=shared_library', npm error gyp info spawn args '-Dvisibility=default', npm error gyp info spawn args '-Dnode_root_dir=/data/data/com.termux/files/home/.cache/node-gyp/22.2.0', npm error gyp info spawn args '-Dnode_gyp_dir=/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp', npm error gyp info spawn args '-Dnode_lib_file=/data/data/com.termux/files/home/.cache/node-gyp/22.2.0/<(target_arch)/node.lib', npm error gyp info spawn args '-Dmodule_root_dir=/data/data/com.termux/files/home/.npm/_cacache/tmp/git-clonePQM76s6fE6PX/node_modules/sharp', npm error gyp info spawn args '-Dnode_engine=v8', npm error gyp info spawn args '--depth=.', npm error gyp info spawn args '--no-parallel', npm error gyp info spawn args '--generator-output', npm error gyp info spawn args 'build', npm error gyp info spawn args '-Goutput_dir=.' npm error gyp info spawn args ] npm error Package xproto was not found in the pkg-config search path. npm error Perhaps you should add the directory containing xproto.pc' npm error to the PKG_CONFIG_PATH environment variable npm error Package 'xproto', required by 'xrender', not found npm error gyp: Undefined variable android_ndk_path in binding.gyp while trying to load binding.gyp npm error gyp ERR! configure error npm error gyp ERR! stack Error:gyp` failed with exit code: 1 npm error gyp ERR! stack at ChildProcess. (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:297:18) npm error gyp ERR! stack at ChildProcess.emit (node:events:520:28) npm error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) npm error gyp ERR! System Linux 4.19.127-g5f63319-dirty npm error gyp ERR! command "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm error gyp ERR! cwd /data/data/com.termux/files/home/.npm/_cacache/tmp/git-clonePQM76s6fE6PX/node_modules/sharp npm error gyp ERR! node -v v22.2.0 npm error gyp ERR! node-gyp -v v10.1.0 npm error gyp ERR! not ok npm error npm error code 1 npm error npm error path /data/data/com.termux/files/home/.npm/_cacache/tmp/git-clonePQM76s6fE6PX/node_modules/sharp npm error npm error command failed npm error npm error command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)

lovell commented 5 months ago

@weskerty Please upgrade to the latest version. If you still require help please open a new installation issue and answer all of the questions.