Since my original post, I've had to resolve Visual Studio, Ionic, Cordova, Phonegap, plugin... environment issue several times. I've found the below works best:
- Ensure platform matches plugin requirements, see platform in config.xml e.g. 6.1.1
- Uninstall, reinstall latest jdk (adobe)
- Clear MEF Cache - download the tool and follow instructions
- Download/install latest node.js
Run the following from the command line:
- Clear cache: Npm cache clean
- Install latest npm: npm install -g npm
- Uninstall cordova: Npm uninstall -g cordova
- Reinstall cordova: Npm install –g cordova (note, this took 5+ tries to complete without errors. No other changes were made between runs. Not sure
why. Found others complaining about the same issue.)
- Remove Android platform: Cordova platform remove android
- Install Cordova platform add android@6.X.X (Note, as of 4/20/17 cordova and android compatibility issue. Build error - unable to find installed version of gradle. resolved by running (npm install -g cordova@6.4.0) and (cordova platform add android@6.1.2). Addt'l build errors, resolved by updating components in Android SDK Manager)
- Uninstall/Reinstall plugins from the command line. For example:
- cordova plugin remove phonegap-plugin-push
- cordova plugin add phonegap-plugin-push variable SENDER_ID="YourID#"
- npm install bower -g
- Restart Visual Studio - Verify plugins were installed via config.xml
Install Ionic:
- npm uninstall -g ionic
- npm install -g ionic (note: to install specific version, npm install -g ionic@2.2.3)
- $ ionic platform add ios
- $ ionic platform add android (note: redundant, already added above)
I recommend putting as much of this as possible in a batch file with a pause between commands. Verify each command was successful, if not press ctrl+break at the pause to term the batch file early. The batch file is an easy way to restore your environment when everything breaks again. Stuff happens!
I also started using a VM (oracle virtualbox) for my development environment. That way I can backup my environment before making changes and easily restore. Don't forget to upload to GIT on a daily basis. GIT and VMs are my lifesavers.
Cool NPM commands:
- npm list (lists all installed packages)
- npm prune (removes packages not depended on by your project according to your package.json)
- npm outdated (tells you which installed packages are outdated with respect to what is current in the npm registry but allowable by the version definition in your package.json. Make sure all up-to-date)
Please feel free to add/make suggestions to the above list.
-Mike