You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Ionic Cordova添加iOS平台失败,求助解决方案

Hey there, let's break down each of these issues and walk through how to fix them step by step—this stuff can be tricky when you're new to Ionic/Cordova, but we'll get you sorted.

1. requireCordovaModule加载非Cordova模块(q/glob)的错误

Here's what's happening: Starting with Cordova 9, the team restricted the use of requireCordovaModule to only load official Cordova core modules. Older versions of plugins like cordova-sqlite-storage and cordova-plugin-statusbar still use this method to load third-party modules (like q or glob), which triggers the error.

Fixes:

  • Update the plugins to their latest versions (most modern plugin versions have fixed this issue):
    First uninstall the old plugins, then install the latest stable builds:
    # Remove outdated plugins
    ionic cordova plugin remove cordova-sqlite-storage
    ionic cordova plugin remove cordova-plugin-statusbar
    
    # Install latest versions
    ionic cordova plugin add cordova-sqlite-storage@latest
    ionic cordova plugin add cordova-plugin-statusbar@latest
    
  • Temporary workaround (if updates don't help):
    If a plugin hasn't been updated to fix this, you can add a preference to config.xml to bypass the restriction (note: this isn't ideal long-term, but it works for immediate builds):
    Add this line either inside the <platform name="ios"> tag or globally in your config.xml:
    <preference name="AllowCordovaModule" value="true" />
    
2. Node Sass不支持当前OS X 64位环境(运行时版本72)的错误

This is a version compatibility issue. Node.js runtime version 72 corresponds to Node.js 12.x, and your installed Node Sass version doesn't support this Node.js release. Node Sass has been deprecated in favor of Dart Sass, so here are your options:

Fixes:

  • Option 1: Install a Node Sass version compatible with Node.js 12.x:
    Node.js 12 works with Node Sass versions 4.12.x to 4.14.x. Uninstall your current Node Sass and install a matching version:
    npm uninstall node-sass
    npm install node-sass@4.14.1 --save-dev
    
  • Option 2: Switch to Dart Sass (Recommended):
    Dart Sass is the official replacement for Node Sass and has better long-term support. Uninstall Node Sass and install Dart Sass instead:
    npm uninstall node-sass
    npm install sass --save-dev
    
    Your project will automatically use Dart Sass for compilation—no extra configuration needed, and it's compatible with most existing Sass code.
3. Reinstalling plugins still triggers the glob error

This is usually due to cached old plugin files or leftover dependencies. A "clean slate" reinstall often fixes this:

Steps:

  1. Clean Cordova's build cache:
    cordova clean ios
    
  2. Clear npm's cache:
    npm cache clean --force
    
  3. Delete all dependency and platform/plugin folders to start fresh:
    rm -rf node_modules package-lock.json platforms plugins
    
  4. Reinstall npm dependencies, add the iOS platform, and reinstall the updated plugins:
    npm install
    ionic cordova platform add ios
    ionic cordova plugin add cordova-sqlite-storage@latest cordova-plugin-statusbar@latest
    

After completing these steps, try running your build command again:

ionic cordova build ios --prod

内容的提问来源于stack exchange,提问作者Premox

火山引擎 最新活动