Can't generate App Icon and Splash Screen (cordova-res / capacitor-assets)

I’m trying to generate the App Icon and Splash Screen for my Ionic Angular app. In the past I did it simply by using:

cordova-res ios --skip-config --copy
(following this guide)

However I now get the following error:

  throw new Error(help.join('\n'));

Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-darwin-x64.node'
Require stack:
- /usr/local/lib/node_modules/cordova-res/node_modules/sharp/lib/sharp.js
- /usr/local/lib/node_modules/cordova-res/node_modules/sharp/lib/constructor.js
- /usr/local/lib/node_modules/cordova-res/node_modules/sharp/lib/index.js
- /usr/local/lib/node_modules/cordova-res/dist/image.js
- /usr/local/lib/node_modules/cordova-res/dist/cli.js
- /usr/local/lib/node_modules/cordova-res/dist/index.js
- /usr/local/lib/node_modules/cordova-res/bin/cordova-res

Possible solutions:
- Install with the --verbose flag and look for errors: "npm install --ignore-scripts=false --verbose sharp"
- Install for the current runtime: "npm install --platform=darwin --arch=x64 sharp"
- Consult the installation documentation:
    at Object.<anonymous> (/usr/local/lib/node_modules/cordova-res/node_modules/sharp/lib/sharp.js:30:9)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/cordova-res/node_modules/sharp/lib/constructor.js:8:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

I already tried fixing it using some advices from this GitHub issue:
Removing cordova-res from the project using npm uninstall cordova-res and install it globally again using npm install -g cordova-res.

That didn’t work, same error again.
I’m using the latest cordova-res@0.15.4.

More about my setup:


   Ionic CLI                     : 6.18.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.0.2
   @angular-devkit/build-angular : 13.0.4
   @angular-devkit/schematics    : 13.0.4
   @angular/cli                  : 13.0.4
   @ionic/angular-toolkit        : 5.0.3


   Capacitor CLI      : 3.3.4
   @capacitor/android : 3.3.4
   @capacitor/core    : 3.3.4
   @capacitor/ios     : 3.3.4


   cordova-res : not installed globally
   native-run  : 1.5.0


   NodeJS : v14.15.4 (/usr/local/bin/node)
   npm    : 6.14.10
   OS     : macOS Big Sur

I ran out of ideas on how to fix this.
Thank you in advance for any help!

Solved by doing the following:

  1. sudo npm uninstall -g cordova-res
  2. brew install vips
  3. sudo npm install -g cordova-res --unsafe-perm=true

(This was suggested for M1 Macs, although I’m on an Intel Mac but that fixed it!)

1 Like