m1 mac
npm install で 'vips/vips8' file not found #include <vips/vips8>
のエラーが出る。
$ npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
> sharp@0.25.4 install /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-darwin-arm64v8.tar.gz
ERR! sharp Prebuilt libvips 8.9.1 binaries are not yet available for darwin-arm64v8
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
CC(target) Release/obj.target/nothing/../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 is empty (no object file members in the library define global symbols)
TOUCH Release/obj.target/libvips-cpp.stamp
CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:23:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/hiroshi.nishigami/.asdf/installs/nodejs/14.17.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:375:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/hiroshi.nishigami/.asdf/installs/nodejs/14.17.1/bin/node" "/Users/hiroshi.nishigami/.asdf/installs/nodejs/14.17.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/sharp
gyp ERR! node -v v14.17.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.25.4 install: `(node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.25.4 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! /Users/hiroshi.nishigami/.npm/_logs/2022-04-22T13_10_57_686Z-debug.log
$ arch -arm64 brew install vips
ref: https://stackoverflow.com/a/66676895
vips を brew install すると、npm install が成功した。
$ gatsby develop
success open and validate gatsby-configs - 0.035s
success load plugins - 9.612s
success onPreInit - 0.026s
info We've detected that the Gatsby cache is incomplete (the .cache directory exists
but the public directory does not). As a precaution, we're deleting your site's
cache to ensure there's no stale data.
success initialize cache - 0.013s
success copy gatsby files - 0.029s
success onPreBootstrap - 0.013s
success createSchemaCustomization - 0.004s
ERROR
Processing /Users/hiroshi.nishigami/work/blog-hakasenote/content/posts/2020/images/2020-07-13-00-48-25.png failed
Original error:
Command failed with ENOENT: /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/pngquant-bin/vendor/pngquant - --strip --quality 50-75
spawn /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/pngquant-bin/vendor/pngquant ENOENT
WorkerError: Processing /Users/hiroshi.nishigami/work/blog-hakasenote/content/posts/2020/images/2020-07-13-00-48-25.png failed
Original error:
Command failed with ENOENT: /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/pngquant-bin/vendor/pngquant - --strip --quality 50-75 spawn /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/pngquant-bin/vendor/pngquant ENOENT
- jobs-manager.ts:318 enqueueJob
[blog-hakasenote]/[gatsby]/src/utils/jobs-manager.ts:318:21
- task_queues.js:95 processTicksAndRejections
internal/process/task_queues.js:95:5
not finished source and transform nodes - 1.560s
not finished Generating image thumbnails - 0.403s
Command failed with ENOENT pngquant
エラーが出ている。
node_modules/pngquant-bin/vendor/pngquant
が存在していないことが原因と考えられる。
以下のように、 node_modules/pngquant-bin
の中で npm install すると、解決した。
hiroshi.nishigami@N01070097:~/work/blog-hakasenote/node_modules/pngquant-bin (master *%=) [exit: 0] [last: 0s] [20220422-22:27:50]
$ npm install
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 querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
> pngquant-bin@6.0.0 postinstall /Users/hiroshi.nishigami/work/blog-hakasenote/node_modules/pngquant-bin
> node lib/install.js
✔ pngquant pre-build test passed successfully
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN eslint-import-resolver-webpack@0.12.2 requires a peer of webpack@>=1.11.0 but none is installed. You must install peer dependencies yourself.
added 1007 packages from 434 contributors and audited 1008 packages in 37.164s
113 packages are looking for funding
run `npm fund` for details
found 5 vulnerabilities (2 moderate, 3 high)
run `npm audit fix` to fix them, or `npm audit` for details
$ ls vendor/pngquant
vendor/pngquant