Cordova 错误:使用“requireCordovaModule"加载非科尔多瓦模块“q"不支持 [英] Cordova error: Using "requireCordovaModule" to load non-cordova module "q" is not supported

查看:44
本文介绍了Cordova 错误:使用“requireCordovaModule"加载非科尔多瓦模块“q"不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到由于以下错误,我们 CI 上的构建开始失败:

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 to the project

Installing "cordova-plugin-app-version" for android

Adding cordova-plugin-app-version to package.json
Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
[ERROR] Exception: 
The command '/bin/sh -c ionic cordova platforms add android' returned a non-zero code: 1

同样的问题在 iOS 和 Android 上都会发生.

Same issue happens on both iOS and Android.

经过一番挖掘,我发现cordova 9.0.0 最近发布.

After some digging, I found that cordova 9.0.0 was recently released.

有一些与此问题相关的更改.

There are a couple of changes related to this issue.

  • GH-710 放弃 Q 依赖并使用原生 Promises
  • GH-707 弃用非 Cordova 模块的 requireCordovaModule

我的第一个想法是不知何故我们没有锁定我们的cordova版本,但我们确实将其锁定到dockerfile中的cordova@8.1.2.我还在我的本地机器上测试了它,我的科尔多瓦版本 8.1.2 也是如此.所以这不是问题.

My first thought was that somehow we didn't have our cordova version locked, but we did lock it to cordova@8.1.2 in our dockerfile. I also tested it on my local machine and I cordova version 8.1.2 as well. So this can't be the issue.

在查看更多日志后,我注意到了一些这样的日志:

After looking at the logs some more, I noticed some logs like these:

cordova-android 版本检查失败(/app/platforms/android/cordova/version"),仍然继续.

有几个,比如 3 或 4 个,但构建并没有停止.

There were a couple of those, like 3 or 4, but the build did not stop when that happened.

然后我再次运行旧提交的构建,它运行良好,可能是因为某些层被缓存了.但是如果我只更改了一个包(我更新了 prettier 来尝试一下),它会导致大部分层被重新构建,并且构建因上述错误而崩溃.

I then ran the build of an older commit again, and it worked fine, probably because some layers were cached. But if I changed only a single package (I updated prettier to try it out), it caused most of the layers to be rebuilt and the build crashed with the above error.

似乎以某种方式更新了更深层次的某些依赖项,从而导致了问题.

It seems that somehow some dependencies deeper down got updated, which are causing the issue.

感谢您的帮助.

推荐答案

我也遇到了这个问题.就我而言,我需要删除一个有问题的插件 cordova-plugin-camera-preview,它列出了 "cordova": "*" 作为依赖项.这将在 ionic cordova build

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

这篇关于Cordova 错误:使用“requireCordovaModule"加载非科尔多瓦模块“q"不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆