I recently started getting this error when trying to run any Cordova project, whether it is Ionic or just a plain Cordova project.
It allows me to build the project without any issues but if I try to use the commands ionic run android or cordova run android to push to a device or emulator I get the error below:

I have worked on and can confirm that it was working yesterday.
Nothing changed in the mean time. This is on a Windows machine. I have formatted and reinstalled everything which helped for a day then I started receiving the same errors.
NPM version 2.14.12
Ionic version 1.7.12
Cordova version 5.4.1
Java version 1.8.0_66
A hack to solve this (but not a real solution) is to modify file platforms\android\cordova\node_modules\q\q.js on line 1716-1718
From this:
var timeoutId = setTimeout(function () {
deferred.reject(new Error(message || "Timed out after " + ms + " ms"));
}, ms);
To this:
var timeoutId = setTimeout(function () {
deferred.reject(new Error(message || "Timed out after " + ms + " ms"));
}, 15000);
This hack comes from this other stackoverflow question: Visual Studio Cordova - You may not have the required environment or OS to run this project , I didn't mark this one as duplicate because of this better question explanation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With