Cordova error: Using “requireCordovaModule” to load non-cordova module “q” is not supported

后端 未结 14 842
情深已故
情深已故 2020-12-08 12:59

I noticed that the builds on our CI started to fail because of the following error:

Discovered plugin \"cordova-plugin-app-version\" in config.xml. Adding it         


        
相关标签:
14条回答
  • 2020-12-08 13:29

    Seems to be an issue with cordova 9.0.0, see this issue ticket.

    Looks like it is already fixed and will be included in the next (9.0.1?) release.

    0 讨论(0)
  • 2020-12-08 13:29

    That's it, I found it. It comes from an update to cordova cli @9.0.0 and it's append on existing projects.
    The issue come from cordova-android-support-gradle-release and fixed in version latest.

    So in any case, what you need to do is:
    cordova plugin rm cordova-android-support-gradle-release
    cordova plugin add cordova-android-support-gradle-release@latest

    0 讨论(0)
  • 2020-12-08 13:30

    As the error says, you need to require the q. Go to npmInstall.js (Search the requireCordovaModule in your project then you will see the npmInstall.js ).

    Then, add these lines;

    var q = require('q');
    var npmModule = require('npm');
    

    and replace: var Q = context.requireCordovaModule('q'); with

    var Q = context.q;
    

    and replace: var npm = context.requireCordovaModule('npm'); with

    var npm = context.npmModule;
    
    0 讨论(0)
  • 2020-12-08 13:33

    Simple:

    Replace the requireCordovaModule to require :

    requireCordovaModule("q") to require("q")

    0 讨论(0)
  • 2020-12-08 13:34

    I ran into this also. In my case, I needed to remove a problematic plugin cordova-plugin-camera-preview which lists "cordova": "*" as a dependency. This would install cordova 9.0.0 during ionic cordova build

    0 讨论(0)
  • 2020-12-08 13:36

    I have returned to the previous version: 8.1.2.

    npm install -g cordova@8.1.2

    Now, it's working again.

    If you want to stay on the latest version of cordova, go to the following instructions:
    https://stackoverflow.com/a/58956882/9536897

    0 讨论(0)
提交回复
热议问题