ERROR: cordova-res was not found on your PATH

Viewed 23937

I have a problem in my app ionic 4, when i run ionic cordova platform add android I have this error :

[ERROR] cordova-res was not found on your PATH. Please install it globally:
npm i -g cordova-res

And when I run npm i -g cordova-res I cant't install it. How to solve this problem?

10 Answers

There are many offline/local options available for resizing Cordova resources. Ionic even has one now: cordova-res. I started the project in an attempt to deprecate the legacy resources service as soon as possible. You can try it today:

npm i -g cordova-res
ionic cordova resources --cordova-res

Hope this will help, Cheers !

Install and save cordova-res to your project node_modules.

npm i cordova-res@latest --save

then execute,

ionic cordova resources ios --force

In our team, we avoid installing modules globally as it can lead to system permission issues or mess up other projects, so even though the terminal says to install globally, we installed locally to the project and as a dev dependency:

npm install cordova-res --save-dev

Also word to the wise, since ionic v4 isn't the latest version of ionic anymore (v5 at the time of this post), if they update the latest cordova-res module, it might not be backwards compatible. So the version we used which is the latest version at this time is ^0.9.0:

package.json:

 ...
 "devDependencies": {
    ...
    "cordova-res": "^0.9.0",
    ...
  },
  ...

Try this command:

sudo npm i -g cordova-res --unsafe-perm

Seems to be fixed now. Ionic just released a new version. What I did was npm i -g cordova ionic and then npm i -g cordova-res

I fixed this issue using the following command:

sudo npm i -g cordova-res --unsafe-perm

try use this command

ionic cordova resources android --force

Normally this kind of problem is something to do with the order of your PATH environment variable.

Some things include some other things, like visual studio ships with its own copy of some open source utils and if its higher up in the path list and it finds them there first then it will try to use these old versions instead of what you are expecting.

I don't have an exact answer but I would recommend going to your windows path env screen and looking at the order of the paths in there.

Bump ones related to your issue up closer to the start of the list / top of the list and retest.

Note that some things, like command consoles, cache the path variable so you will have to close and reopen things each time you make a change just to be safe.

To get to the path in Windows 10:

  • Open the Start Search, type in “env”, and choose “Edit the system environment variables”
  • Click the “Environment Variables…” button.
  • Under the “System Variables” section (the lower half), find the row with “Path” in the first column, and click edit.
  • The “Edit environment variable” UI will appear. From this screen you can also edit or reorder them.
  • Dismiss all of the dialogs by choosing “OK”. Your changes are saved!
  • You will probably need to restart apps for them to pick up the change. Restarting the machine would ensure all apps are run with the PATH change.

Source: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/

I have received the error while generating icons and the splash screen with ionic cordova resources. In the Ionic 4 docs I found this hint:

ionic cordova resources will automatically update your config.xml to reflect the changes in the generated images, which Cordova then configures.

This command uses the cordova-res utility to generate resources locally. You can also login to your Ionic account and use Ionic servers to generate icons and splash screens with --no-cordova-res

Source: https://ionicframework.com/docs/cli/commands/cordova-resources

When you create a platform, Ionic will also generate the icons and the splash. If you don't want that, use this command: ionic cordova platform add android --no-resources

Source: https://ionicframework.com/docs/cli/commands/cordova-platform

Try this to install $ npm install cordova-res --save-dev

and then $ ionic cordova resources --icon $ ionic cordova resources --splash

Related