capacitor-assets: Unable to install on mac M1
When I run sudo npm install -g cordova-res --unsafe-perm
I get the following error.
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/cordova-res/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
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/src/common.o
npm ERR! info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-darwin-x64.tar.br
npm ERR! internal/fs/utils.js:307
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: EACCES: permission denied, copyfile ‘/tmp/53567-libvips-8.10.5-darwin-x64.tar.br’ -> ‘/Users/USERNAME/.npm/_libvips/libvips-8.10.5-darwin-x64.tar.br’
npm ERR! at Object.copyFileSync (fs.js:1991:3)
npm ERR! at WriteStream.<anonymous> (/usr/local/lib/node_modules/cordova-res/node_modules/sharp/install/libvips.js:133:16)
npm ERR! at WriteStream.emit (events.js:315:20)
npm ERR! at emitCloseNT (internal/streams/destroy.js:87:10)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:79:21) {
npm ERR! errno: -13,
npm ERR! syscall: ‘copyfile’,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/tmp/53567-libvips-8.10.5-darwin-x64.tar.br’,
npm ERR! dest: ‘/Users/USERNAME/.npm/_libvips/libvips-8.10.5-darwin-x64.tar.br’
npm ERR! }
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.16.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at “/usr/local/opt/python@3.9/bin/python3.9”
npm ERR! gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args ‘/usr/local/lib/node_modules/npm/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 ‘/usr/local/lib/node_modules/cordova-res/node_modules/sharp/build/config.gypi’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘/Users/USERNAME/Library/Caches/node-gyp/14.16.0/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/USERNAME/Library/Caches/node-gyp/14.16.0’,
npm ERR! gyp info spawn args ‘-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp’,
npm ERR! gyp info spawn args ‘-Dnode_lib_file=/Users/USERNAME/Library/Caches/node-gyp/14.16.0/<(target_arch)/node.lib’,
npm ERR! gyp info spawn args ‘-Dmodule_root_dir=/usr/local/lib/node_modules/cordova-res/node_modules/sharp’,
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! gyp info spawn make
npm ERR! gyp info spawn args [ ‘BUILDTYPE=Release’, ‘-C’, ‘build’ ]
npm ERR! 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)
npm ERR! In file included from …/src/common.cc:24:
npm ERR! /usr/local/include/vips/vips8:35:10: fatal error: ‘glib-object.h’ file not found
npm ERR! #include <glib-object.h>
npm ERR! ^~~~~~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/sharp/src/common.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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.3.0
npm ERR! gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/cordova-res/node_modules/sharp
npm ERR! gyp ERR! node -v v14.16.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
Here is my environment info:
Ionic:
Ionic CLI : 6.13.1
Utility:
cordova-res : not installed native-run : not installed
System:
NodeJS : v14.16.0 npm : 7.6.3 OS : macOS Big Sur
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 35 (2 by maintainers)
Commits related to this issue
- Bump sharp version to fix #266 #206 — committed to ionic-team/capacitor-assets by mlynch 3 years ago
I’m on a MacBook Air with the M1 chip.
node v16.11.1 npm v8.0.0
I was seeing the exact error mentioned by jmkni. Running
brew install vips
fixed the issue for me (install took some time).@imhoffd Please have a look into this PR #216
This worked for me too on M1 Pro chip, though had to also run
brew install libheif
.I use the following command to install the npm package of the MR:
@fr3fou
I suggest trying again. it looks like the binaries are out now. Make sure your terminal is not running under rosetta.
npm -g i sharp npm -g i cordova-res
Thanks everyone, will make sure to bump the versions of sharp when we release 1.0. Keep in mind Cordova support will be dropped from 1.0 and it will be Capacitor only. Happy to do a patch release before that for older versions if you still need Cordova support.
many thanks @MaaxGr ! I also need to do cd /opt/homebrew/lib/node_modules/cordova-res and npm install to create the dist folder
@donhmorris Even though the new binaries are available, they will only install with 0.28 and up. I tried installing this specific version in my project but the install script still sticks to 0.27.2 even if you do
npm i sharp@0.28.1
. I think this will only work correctly if cordova-res updates their dependency to 0.28.XSee: https://github.com/lovell/sharp-libvips/issues/71
Hi guys. I’m here to help you after a lot of trying and searching with all obviously updated recenty.
After I tried all the solutions described in this thread I solved in this way:
Tested with brand new Macbook Pro 16 with M1 Pro
Goodluck guys! 💪🚀
This works for me on M1 Pro
I have found running latest node 16 works best for me. Prior to m1, I ran the lts version of node.
@MaaxGr thanks for solution and @davidecampello thanks for the clue!
I’m using nvm and I do
In my case I also needed to run
npm run build
ok, thanks