You can install the latest version of Ionic and Cordova CLI using a single command
$ npm install ionic cordova -g
Still, you may get a notification message saying
“Please install your Cordova CLI to version >=4.2.0 `npm install -g cordova`”
Or, incorrect version numbers for ionic and cordova even after installing their latest versions globally.
In these situations, you can try the following options
i) Clear npm cache
$ npm cache clean -f
ii) Update npm globally
$ npm install npm -g
If the problem persists, try uninstalling both ionic and cordova and then re-install it again to see if this fixes the issue.