capacitor-assets
capacitor-assets copied to clipboard
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.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
same error but i found a solution
https://sharp.pixelplumbing.com/install#apple-m1
-- node: 15.11.0 npm: 7.6.0 OS: macOS Bis Sur 11.2.3 (20D91)
I had the same problem. I followed the link @julienmiclo posted and everything worked after i installed the sharp graphics library.
node v15.12.0 npm v7.6.3 darwin v11.2.3
I'm still having issues even after installing Sharp with the --build-from-source flag
@jmkni do you have more info? Node version, etc.
@donhmorris Sure
Node version - v15.12.0 Npm version - v7.6.3
Error:
npm ERR! code 1
npm ERR! path /opt/homebrew/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-arm64v8.tar.br
npm ERR! ERR! sharp Prebuilt libvips 8.10.5 binaries are not yet available for darwin-arm64v8
npm ERR! info sharp Attempting to build from source via node-gyp but this may fail due to the above error
npm ERR! info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/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 '/opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/johnmckay/Library/Caches/node-gyp/15.12.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/johnmckay/Library/Caches/node-gyp/15.12.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/johnmckay/Library/Caches/node-gyp/15.12.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/homebrew/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: /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! ../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
npm ERR! #include <vips/vips8>
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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:369:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.3.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/15.12.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp
npm ERR! gyp ERR! node -v v15.12.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/johnmckay/.npm/_logs/2021-04-01T17_54_05_088Z-debug.log
Let me know if you'd like a copy of that log file.
Thanks
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
Still getting the same issue unfortunately @donhmorris , and not running under Rosetta!
I wish i could help more. I got this to work while trying to build the native (IOS and Android) versions of my app. I did a lot of stuff to get the capacitor build tool to work. One of the thing i had to do was install cocoapods using the -acrh64 flag. Unfortunately its all jumbled together and I can't remember which step fixed what. I do know that I can install and use the cordova-res tool with no problems now.
No worries @donhmorris , appreciate the replies!
I still have my Intel machine so using that in the mean time, so not slowing me down :)
Thanks
@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 [email protected]
. I think this will only work correctly if cordova-res updates their dependency to 0.28.X
See: https://github.com/lovell/sharp-libvips/issues/71
ok, thanks
@donhmorris there is a PR for this: https://github.com/ionic-team/cordova-res/pull/216
Is there a timeline for the merge & release?
@imhoffd forgot to tag you in the comment above
@imhoffd Please have a look into this PR #216
Any work around to install it until #216 gets merged?
I use the following command to install the npm package of the MR:
npm install -g https://github.com/rubenstolk/cordova-res/tarball/patch-1
@fr3fou
many thanks @MaaxGr ! I also need to do cd /opt/homebrew/lib/node_modules/cordova-res and npm install to create the dist folder
@MaaxGr thanks for solution and @davidecampello thanks for the clue!
I'm using nvm and I do
cd /Users/monurakkaya/.nvm/versions/node/v14.17.1/lib/node_modules/cordova-res && npm install && npm run build
In my case I also needed to run npm run build
I've globally installed the patch mentioned by @MaaxGr and ran npm install in the cordova-res folder (also using nvm) but I can't seem to run the build command:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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/adam/.npm/_logs/2021-10-14T11_27_43_749Z-debug.log
Contents of the folder:
drwxr-xr-x 8 adam staff 256 Oct 14 13:26 .
drwxr-xr-x 12 adam staff 384 Oct 14 13:19 ..
-rw-r--r-- 1 adam staff 1072 Oct 26 1985 LICENSE
-rw-r--r-- 1 adam staff 3887 Oct 26 1985 README.md
drwxr-xr-x 3 adam staff 96 Oct 14 13:13 bin
drwxr-xr-x 652 adam staff 20864 Oct 14 13:26 node_modules
-rw-r--r-- 1 adam staff 415624 Oct 14 13:26 package-lock.json
-rw-r--r-- 1 adam staff 2782 Oct 14 13:25 package.json
I suppose I'm missing files here?
EDIT: I was running node 14, switching to the following version fixed my problem: node v15.14.0 npm 7.7.6 using npm -g i cordova-res
I have found running latest node 16 works best for me. Prior to m1, I ran the lts version of node.
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).
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).
This is the solution that worked in my case: MacBook Pro 16" with M1 Max chip.
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.
brew install vips
This worked for me too on M1 Pro chip, though had to also run brew install libheif
.
Thank you @hardikdabhi
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).
This works for me on M1 Pro
npm install -g --arch=arm64 --platform=darwin sharp
brew install vips
@mlynch I think it would be quite unwise to drop Cordova support for this library.
Two reasons:
- keeping Cordova compatibility should be a trivial affair nowadays, I'm happy to do that work if someone wants to do it
- Cordova is not deprecated, it's still an active Apache supported project and has an active community that could use this
- While I don't mind migrating to Capacitor from Cordova eventually if that's where things end up, there's little reason to do so right now, and cutting off Cordova users will just cause fragmentation as a fork will likely be fired up
@jpike88 appreciate the feedback. For Cordova users they can still stick with the cordova-res
tool that will continue to work, so no problems there. Happy to do a patch release for that version as well for this M1 fix.
Moving forward, we think Capacitor provides a much better developer experience and we're starting to build out a whole ecosystem of functionality around it (for example, the new Capacitor Configure utility we released a few weeks ago). We really want to encourage developers to make the switch to Capacitor because we know they'll be happier and will be better aligned with the rest of the Ionic stack and where we're taking it. And, at the end of the day, it has a non-zero cost for us to build Cordova and Capacitor versions of things and we think that energy would be better spent innovating on top of the superior foundation that Capacitor affords us.
PR https://github.com/ionic-team/capacitor-assets/pull/262 should fix the issue;
https://github.com/lovell/sharp/issues/2460#issuecomment-811046375
It's fixed