Did you see the documentation relating to installation?
yes
Have you ensured the architecture and platform of Node.js used for npm install is the same as the architecture and platform of Node.js used at runtime?
yes
Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?
yes
If you are installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?
yes when I ues npm install --unsafe-perm flag ,it didn't work. The error is the same.
If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?
I am not using that feature
What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?
npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/usr/local/node/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli '--verbose',
npm verb cli 'sharp'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session b6e9d019f8f8e2ef
npm http fetch GET 304 https://registry.npm.taobao.org/sharp 413ms (from cache)
npm timing stage:loadCurrentTree Completed in 1044ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 4ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 348ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 329ms
npm timing stage:loadIdealTree Completed in 859ms
npm timing stage:generateActionsToTake Completed in 32ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-fe1316a61e55350c.lock for /var/testImageServer/node_modules/.staging
npm timing action:extract Completed in 119ms
npm http fetch POST 404 https://registry.npm.taobao.org/-/npm/v1/security/audits/quick 156ms
npm timing action:finalize Completed in 13ms
npm timing action:refresh-package-json Completed in 23ms
npm info lifecycle [email protected]~preinstall: [email protected]
npm timing action:preinstall Completed in 4ms
npm info linkStuff [email protected]
npm timing action:build Completed in 4ms
npm info lifecycle [email protected]~install: [email protected]
> [email protected] install /var/testImageServer/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Detected globally-installed libvips v8.10.2
info sharp Building from source via node-gyp
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli '/usr/local/node/bin/node',
gyp verb cli '/usr/local/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild'
gyp verb cli ]
gyp info using [email protected]
gyp info using [email protected] | linux | arm64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
gyp verb find Python - executable path is "/usr/bin/python"
gyp verb find Python - executing "/usr/bin/python" to get version
gyp verb find Python - version is "2.7.16"
gyp info find Python using Python version 2.7.16 found at "/usr/bin/python"
gyp verb get node dir no --target version specified, falling back to host node version: 12.19.0
gyp verb command install [ '12.19.0' ]
gyp verb install input version string "12.19.0"
gyp verb install installing version: 12.19.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 12.19.0
gyp verb build dir attempting to create "build" dir: /var/testImageServer/node_modules/sharp/build
gyp verb build dir "build" dir needed to be created? /var/testImageServer/node_modules/sharp/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /var/testImageServer/node_modules/sharp/build/config.gypi
gyp verb config.gypi checking for gypi file: /var/testImageServer/node_modules/sharp/config.gypi
gyp verb common.gypi checking for gypi file: /var/testImageServer/node_modules/sharp/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args '/usr/local/node/lib/node_modules/npm/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 '/var/testImageServer/node_modules/sharp/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/node/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.cache/node-gyp/12.19.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=/root/.cache/node-gyp/12.19.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/node/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/12.19.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/var/testImageServer/node_modules/sharp',
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 verb command build []
gyp verb build type Release
gyp verb architecture arm64
gyp verb node dev dir /root/.cache/node-gyp/12.19.0
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/var/testImageServer/node_modules/sharp/build'
cc '-DNODE_GYP_MODULE_NAME=nothing' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' -I/root/.cache/node-gyp/12.19.0/include/node -I/root/.cache/node-gyp/12.19.0/src -I/root/.cache/node-gyp/12.19.0/deps/openssl/config -I/root/.cache/node-gyp/12.19.0/deps/openssl/openssl/include -I/root/.cache/node-gyp/12.19.0/deps/uv/include -I/root/.cache/node-gyp/12.19.0/deps/zlib -I/root/.cache/node-gyp/12.19.0/deps/v8/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -O3 -fno-omit-frame-pointer -MMD -MF ./Release/.deps/Release/obj.target/nothing/../node-addon-api/nothing.o.d.raw -Wall -arch arm64 -miphoneos-version-min=8.0 -funwind-tables -c -o Release/obj.target/nothing/../node-addon-api/nothing.o ../../node-addon-api/nothing.c
cc: error: arm64: No such file or directory
cc: error: unrecognized command line option ‘-arch’; did you mean ‘-march=’?
cc: error: unrecognized command line option ‘-miphoneos-version-min=8.0’
make: *** [../node-addon-api/nothing.target.mk:107: Release/obj.target/nothing/../node-addon-api/nothing.o] Error 1
make: Leaving directory '/var/testImageServer/node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.47-OPENFANS+20200622-v8
gyp ERR! command "/usr/local/node/bin/node" "/usr/local/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/testImageServer/node_modules/sharp
gyp ERR! node -v v12.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm verb lifecycle [email protected]~install: unsafe-perm in lifecycle false
npm verb lifecycle [email protected]~install: PATH: /usr/local/node/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/testImageServer/node_modules/sharp/node_modules/.bin:/var/testImageServer/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
npm verb lifecycle [email protected]~install: CWD: /var/testImageServer/node_modules/sharp
npm info lifecycle [email protected]~install: Failed to exec install script
npm timing action:install Completed in 2763ms
npm verb unlock done using /root/.npm/_locks/staging-fe1316a61e55350c.lock for /var/testImageServer/node_modules/.staging
npm timing stage:rollbackFailedOptional Completed in 34ms
npm timing stage:runTopLevelLifecycles Completed in 5088ms
npm WARN enoent ENOENT: no such file or directory, open '/var/testImageServer/package.json'
npm verb enoent This is related to npm not being able to find a file.
npm verb enoent
npm WARN testImageServer No description
npm WARN testImageServer No repository field.
npm WARN testImageServer No README data
npm WARN testImageServer No license field.
npm verb stack Error: [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm verb stack Exit status 1
npm verb stack at EventEmitter.<anonymous> (/usr/local/node/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
npm verb stack at EventEmitter.emit (events.js:314:20)
npm verb stack at ChildProcess.<anonymous> (/usr/local/node/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
npm verb stack at ChildProcess.emit (events.js:314:20)
npm verb stack at maybeClose (internal/child_process.js:1021:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
npm verb pkgid [email protected]
npm verb cwd /var/testImageServer
npm verb Linux 5.4.47-OPENFANS+20200622-v8
npm verb argv "/usr/local/node/bin/node" "/usr/local/bin/npm" "install" "--verbose" "sharp"
npm verb node v12.19.0
npm verb npm v6.14.8
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] 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 [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 6263ms
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-11-29T13_25_19_070Z-debug.log
cc: error: arm64: No such file or directory
The libvips was installed according to the instructions: https://libvips.github.io/libvips/install.html#building-libvips-from-a-source-tarball.
Next, I installed sharp. At this point, everything seems to be in line with expectations.
And I tried to make a resize image demo.But an error is prompted. VipsOperation: class "jpegsave" not found
When I tried to install the libjpeg, the system reported cc: error: arm64: No such file or directory.
What is the output of running npx envinfo --binaries --system?
Raspberry Pi 4B
System:
OS: Linux 5.4 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (4) arm64 unknown
Memory: 421.39 MB / 3.71 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 12.19.0 - /usr/local/bin/node
npm: 6.14.8 - /usr/local/bin/npm
Hi, the salient part of the installation log is:
cc '-DNODE_GYP_MODULE_NAME=nothing' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' -I/root/.cache/node-gyp/12.19.0/include/node -I/root/.cache/node-gyp/12.19.0/src -I/root/.cache/node-gyp/12.19.0/deps/openssl/config -I/root/.cache/node-gyp/12.19.0/deps/openssl/openssl/include -I/root/.cache/node-gyp/12.19.0/deps/uv/include -I/root/.cache/node-gyp/12.19.0/deps/zlib -I/root/.cache/node-gyp/12.19.0/deps/v8/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -O3 -fno-omit-frame-pointer -MMD -MF ./Release/.deps/Release/obj.target/nothing/../node-addon-api/nothing.o.d.raw -Wall -arch arm64 -miphoneos-version-min=8.0 -funwind-tables -c -o Release/obj.target/nothing/../node-addon-api/nothing.o ../../node-addon-api/nothing.c
cc: error: arm64: No such file or directory
cc: error: unrecognized command line option ‘-arch’; did you mean ‘-march=’?
cc: error: unrecognized command line option ‘-miphoneos-version-min=8.0’
The part that says -Wall -arch arm64 -miphoneos-version-min=8.0 -funwind-tables is injected from the environment in which you're running npm. Have you set a custom CFLAGS environment variable?
Thank you for your reply.
I'm not sure.I did not actively set.
I try echo $CFLAGS.There is no output.
Something in your local build environment is setting these values so you'll need to find it and remove them.
(If it helps, they appear to be the sort of thing that you might have previously set when cross-compiling for Apple mobile devices, e.g. https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md#armv8-64-bit )
okay,I'll try it later.
sharp has been successfully installed.
In fact, we should clear the build path and re install libjpeg with export CFLAGS="".
But when I tried to run the image resize demo,it reported the following error:
const sharp = require("sharp");
async function testTime(fn){
const start = new Date();
await fn();
const end = new Date();
console.log(end-start);
}
testTime(async function(){
await sharp("./flower.png").resize(800).toFile("out.jpeg");
});
(node:13966) UnhandledPromiseRejectionWarning: Error: VipsOperation: class "jpegsave" not found
(node:13966) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13966) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I'm sure I installed the libjpeg
root@cluster-node1:/var/testImageServer# ldconfig -v | grep jpeg
ldconfig: Can't stat /usr/local/lib/aarch64-linux-gnu: No such file or directory
ldconfig: Path `/lib/aarch64-linux-gnu' given more than once
ldconfig: Path `/usr/lib/aarch64-linux-gnu' given more than once
ldconfig: /lib/aarch64-linux-gnu/ld-2.28.so is the dynamic linker, ignoring
libjpeg.so.62 -> libjpeg.so.62.2.0
libturbojpeg.so.0 -> libturbojpeg.so.0.1.0
libmjpegutils-2.1.so.0 -> libmjpegutils-2.1.so.0.0.0
Error: VipsOperation: class "jpegsave" not found
You'll need to compile libvips with support for libjpeg(-turbo).
ok,I got it.Thank you very much.
support 8bpp PNG quantisation: no
(requires libimagequant)
file import/export with libtiff: no
file import/export with giflib: no
file import/export with libjpeg: no
image pyramid export: no
(requires libgsf-1 1.14.26 or later)
use libexif to load/save JPEG metadata: no
When I tried to reload libvips, libjpeg still showed no effect.
root@cluster-node1:~/vips-8.10.2# ldconfig -p |grep jpeg
libturbojpeg.so.0 (libc6,AArch64) => /usr/lib/aarch64-linux-gnu/libturbojpeg.so.0
libmjpegutils-2.1.so.0 (libc6,AArch64) => /usr/lib/aarch64-linux-gnu/libmjpegutils-2.1.so.0
libjpeg.so.62 (libc6,AArch64) => /usr/lib/aarch64-linux-gnu/libjpeg.so.62
./configure \
--with-libjpeg-includes=/usr/lib/aarch64-linux-gnu \
--with-libjpeg-libraries=/usr/lib/aarch64-linux-gnu
I use this method to try to install libvips
Have the libjpeg header files been installed? https://packages.debian.org/buster/libjpeg62-turbo-dev
perfect,In line with expectations.
For the first time for me, use it on raspberry.
I'm going to build a picture service on raspberry 4B cluster, and generate performance reports for raspberry system.
If you are interested, I will share the experimental results with you.
Most helpful comment
Have the libjpeg header files been installed? https://packages.debian.org/buster/libjpeg62-turbo-dev