Ionic-cli: Something went wrong installing the "sharp" module

Created on 14 Jun 2019  路  6Comments  路  Source: ionic-team/ionic-cli

Description:

i'm use ionic cordova resources ios --force command
if ionic-cli 5.0.2 will be error Something went wrong installing the "sharp" module
but ionic-cli 4.12.0 is ok

Steps to Reproduce:

Output:

D:\WEB\ConsentApp>ionic cordova resources ios --force

cordova-res.cmd ios
[cordova-res]
[cordova-res] Something went wrong installing the "sharp" module
[cordova-res]
[cordova-res] The specified module could not be found.
[cordova-res] \?\D:\WEB\ConsentAppnode_modulessharp\build\Releasesharp.node
[cordova-res]
[cordova-res] - Remove the "node_modules/sharp" directory, run "npm install" and look for errors
[cordova-res] - Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
[cordova-res] - Search for this error at https://github.com/lovell/sharp/issues
[cordova-res]
[ERROR] An error occurred while running subprocess cordova-res.

    cordova-res.cmd ios exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

My ionic info:

<paste here>

Other Information:

triage

Most helpful comment

This isn't really a bug in Ionic CLI. You'll have to fix the installation of sharp, which is the image processing dependency of cordova-res. I noticed you have the tool installed in your project, which isn't our recommended strategy.

Install it globally:

  1. First, remove it from your project: npm uninstall cordova-res
  2. Install globally: npm install -g cordova-res

Here are some more things you can try (keep in mind you will need the -g flag in npm for working with global installations):

Also, you can pass the --no-cordova-res flag to use the old method (remote resource generation).

All 6 comments

This isn't really a bug in Ionic CLI. You'll have to fix the installation of sharp, which is the image processing dependency of cordova-res. I noticed you have the tool installed in your project, which isn't our recommended strategy.

Install it globally:

  1. First, remove it from your project: npm uninstall cordova-res
  2. Install globally: npm install -g cordova-res

Here are some more things you can try (keep in mind you will need the -g flag in npm for working with global installations):

Also, you can pass the --no-cordova-res flag to use the old method (remote resource generation).

sudo npm uninstall cordova-res && sudo npm install -g cordova-res --unsafe-perm=true

its work thankxx brother

sudo npm install -g cordova-res --unsafe-perm=true

I had sharp installed locally too, so did both uninstall and uninstall -g on both cordova-res and sharp

Then install -g cordova-res with --unsafe-perm (and that pulled in sharp) => Bob's my uncle

For Apple M1 sudo npm uninstall -g cordova-res then brew install vips and finally sudo npm install -g cordova-res --unsafe-perm=true

@Florian-crg how you avoid this error once executing ionic cordova resources?

> cordova-res
[cordova-res] /opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/lib/constructor.js:34
[cordova-res]   throw new Error(error);
[cordova-res]   ^
[cordova-res] 
[cordova-res] Error: 
[cordova-res] Something went wrong installing the "sharp" module
[cordova-res] 
[cordova-res] dlopen(/opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/build/Release/sharp.node, 1): Symbol not found: __ZTVN4vips7VOptionE
[cordova-res]   Referenced from: /opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/build/Release/sharp.node
[cordova-res]   Expected in: flat namespace
[cordova-res]  in /opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/build/Release/sharp.node
[cordova-res] 
[cordova-res] - Remove the "node_modules/sharp" directory then run
[cordova-res]   "npm install --ignore-scripts=false --verbose" and look for errors
[cordova-res] - Consult the installation documentation at https://sharp.pixelplumbing.com/install
[cordova-res] - Search for this error at https://github.com/lovell/sharp/issues
[cordova-res] 
[cordova-res]     at Object.<anonymous> (/opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/lib/constructor.js:34:9)
[cordova-res]     at Module._compile (internal/modules/cjs/loader.js:1063:30)
[cordova-res]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
[cordova-res]     at Module.load (internal/modules/cjs/loader.js:928:32)
[cordova-res]     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
[cordova-res]     at Module.require (internal/modules/cjs/loader.js:952:19)
[cordova-res]     at require (internal/modules/cjs/helpers.js:88:18)
[cordova-res]     at Object.<anonymous> (/opt/homebrew/lib/node_modules/cordova-res/node_modules/sharp/lib/index.js:3:15)
[cordova-res]     at Module._compile (internal/modules/cjs/loader.js:1063:30)
[cordova-res]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

Because i did all that steps and is not working still

Was this page helpful?
0 / 5 - 0 ratings