求助:更新Visual Studio中的Apache Cordova工具以兼容插件
Fixing Cordova Version Compatibility for OneSignal in Visual Studio 2017
Hey there! I’ve been in your shoes before—outdated Cordova versions can break plugin compatibility fast, especially with tools like OneSignal. Let’s walk through how to upgrade your Cordova version in VS2017 to get things working smoothly:
Step 1: Check Built-in Cordova Version Options
First, see if Visual Studio already offers a compatible version you can switch to:
- Open Visual Studio 2017
- Navigate to
Tools > Options - Go to
Tools for Apache Cordova > Cordova Tools - Look at the Cordova CLI Version dropdown. If a version like 8.x or 9.x (known to work with OneSignal) is listed, select it, click OK, and restart VS to apply the change.
Step 2: Install a Custom Cordova Version via npm
If the version you need isn’t in the dropdown, install it manually using npm:
- Open Command Prompt (or PowerShell) as an administrator
- Run this command to install your desired version (replace
9.0.0with a version confirmed compatible with OneSignal—check their plugin docs for the latest recommended version):npm install -g cordova@9.0.0 - Verify the installation succeeded with:
cordova -v
Step 3: Configure VS to Use Your Custom Version
Now tell Visual Studio to use the manually installed Cordova:
- Go back to
Tools > Options > Tools for Apache Cordova > Cordova Tools - Select Use a custom version of Cordova
- Click Browse and navigate to the npm installation path (this is typically):
C:\Users\[YourUsername]\AppData\Roaming\npm\node_modules\cordova - Click OK and restart Visual Studio to apply the setting.
Step 4: Refresh Your Project’s Plugins and Platforms
After upgrading, you’ll need to clean up and reinitialize your project’s dependencies:
- Delete the
platformsandpluginsfolders in your Cordova project (they’ll be regenerated automatically) - Open your project’s
config.xmlin VS, go to the Plugins tab, and re-add the OneSignal plugin. Ensure you’re installing a version that matches your new Cordova version. - Alternatively, run this command in your project directory to add the plugin directly:
cordova plugin add onesignal-cordova-plugin@latest
Quick Tips to Avoid Headaches
- VS2017’s Cordova tools have limited support for very new Cordova versions (like 10+), so stick to stable releases like 8.1.0 or 9.0.0 if you run into build issues.
- If you get errors after upgrading, double-check that all other plugins in your project are compatible with the new Cordova version—some older plugins might need updates too.
内容的提问来源于stack exchange,提问作者Nima Yazdi
相关产品推荐
相关产品推荐

