ionic-team / ionic-team/capacitor-assets
sharp issues on mac silicon m4
- Dominant language
- TypeScript
- Stars
- 583
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
Had a bunch of issues trying to get this to work, so I thought I would post my notes about how I got around this problem:
```
npx @capacitor/assets generate ─╯
/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/lib/sharp.js:37
throw new Error(help.join('\n'));
^
Error:
Something went wrong installing the "sharp" module
dlopen(/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node, 0x0001): tried: '/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node' (no such file), '/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/build/Release/sharp-darwin-arm64v8.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current darwin-arm64v8 runtime: "npm install --platform=darwin --arch=arm64v8 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
at Object. (/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/lib/sharp.js:37:9)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object..js (node:internal/modules/cjs/loader:1699:10)
at Module.load (node:internal/modules/cjs/loader:1313:32)
at Function._load (node:internal/modules/cjs/loader:1123:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1335:12)
at require (node:internal/modules/helpers:136:16)
at Object. (/Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/node_modules/@capacitor/assets/node_modules/sharp/lib/constructor.js:11:1)
Node.js v22.13.1
```
Basically I tried a bunch of things, one was putting a override in package.json:
```
"overrides": {
"@capacitor/assets": {
"sharp": "^0.34.1"
}
}
```
and then run `npm i`
That did not fix it but it might have been required in the process so I'm including it.
Then I did the advice [here](https://stackoverflow.com/a/75852216/156388):
```
npm install --platform=darwin --arch=x64 sharp
npm rebuild --platform=darwin --arch=arm64 sharp
```
It gave some warnings about not knowing the params:
```
npm install --platform=darwin --arch=x64 sharp ─╯
npm warn Unknown cli config "--platform". This will stop working in the next major version of npm.
npm warn Unknown cli config "--arch". This will stop working in the next major version of npm.
up to date, audited 1582 packages in 6s
```
and then
```
╰─ npm rebuild --platform=darwin --arch=arm64 sharp ─╯
npm warn Unknown cli config "--platform". This will stop working in the next major version of npm.
npm warn Unknown cli config "--arch". This will stop working in the next major version of npm.
rebuilt dependencies successfully
```
but it did something that worked:
```
╰─ npx @capacitor/assets generate ─╯
No assets found in the asset path /Users/matthewharris/rtp/rtpSoftware/Ionic/BeerBargain/BeerBargainApp/src/assets. See https://github.com/ionic-team/capacitor-assets to learn how to use this tool.
```
So i still have issues, but im past the `sharp` related one... hope this helps somebody.
Contributor guide
Assessment
This issue has not been assessed yet.