17

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?

franiis
  • 1,378
  • 1
  • 18
  • 33
  • I created this bounty. To reproduce this issue run: `npm i cordova ionic -g` and then inside the project `ionic cordova resources` – olivier Jun 25 '19 at 11:13
  • use this commend sudo npm i cordova-res@latest --save –  Sep 19 '19 at 10:37

9 Answers9

12

Install and save cordova-res to your project node_modules.

npm i cordova-res@latest --save

then execute,

ionic cordova resources ios --force
haron68
  • 741
  • 1
  • 5
  • 19
  • I noticed outdated node and npm causes conflicts and the above does not work. In that case this helps: https://stackoverflow.com/a/19333717/1051391 – Jason Oct 31 '19 at 18:22
  • 1
    Don't know why the correct answer got deleted but you can now do `npm i -g cordova-res` to install cordova-res package globally – haron68 Jan 31 '23 at 06:32
8

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",
    ...
  },
  ...
Mark Thompson
  • 448
  • 5
  • 7
  • This helped me, i installed it as --save-dev and that worked immidiately, otherwise, on Ionic info, i could not make cordova-res as installed as globally. Somehow it was not recognizing it as installed. Great choise. – miloth Sep 04 '21 at 14:24
5

Try this command:

sudo npm i -g cordova-res --unsafe-perm
double-beep
  • 5,031
  • 17
  • 33
  • 41
3

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

olivier
  • 2,585
  • 6
  • 34
  • 61
2

I fixed this issue using the following command:

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

ahmnouira
  • 1,607
  • 13
  • 8
2

try use this command

ionic cordova resources android --force
Abd Abughazaleh
  • 4,615
  • 3
  • 44
  • 53
1

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/

rtpHarry
  • 13,019
  • 4
  • 43
  • 64
  • did you look into it though? The concept of path is on both platforms and is process front to back. You will need to do whatever the mac steps are to edit path but I still think this is the likely cause. – rtpHarry Jun 19 '19 at 09:56
1

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

pfleigi
  • 186
  • 3
  • 8
0

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

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

Aarej
  • 318
  • 4
  • 13