xcode Cordova 4.3.0 - 构建命令返回错误找不到模块“Q”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28898012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:46:29  来源:igfitidea点击:

Cordova 4.3.0 - build command returns error Cannot find module 'Q'

xcodecordovanpmnode-modulescordova-cli

提问by MeV

After updating cordova to version 4.3.0 the command:

将cordova更新到4.3.0版后,命令:

cordova build

returns the following error:

返回以下错误:

    module.js:340
    throw err;
          ^
Error: Cannot find module 'Q'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/lib/check_reqs.js:25:13)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
ERROR building one of the platforms: Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)

I have already tried to remove and add the platform ios but nothing changes.

我已经尝试删除和添加平台 ios 但没有任何变化。

I have tried to run:

我试图运行:

sudo npm install -g cordova / sudo npm install cordova
sudo npm install -g Q / sudo npm install Q

but nothing changes.

但没有任何变化。

Any help? Thank you very much

有什么帮助吗?非常感谢

回答by MeV

There was a bug and I have released a patch to it:

有一个错误,我已经发布了一个补丁:

Apache Cordova ios - Git Repository

Apache Cordova ios - Git 存储库

回答by javierfish

This is a bug shown on case-sensitive systems such as Unix, Linux and some OS X (if set as case-sensitive).

这是在区分大小写的系统上显示的错误,例如 Unix、Linux 和某些 OS X(如果设置为区分大小写)。

So far, to fix it, you have to locate those files containing a line like this:

到目前为止,要修复它,您必须找到包含这样一行的文件:

 Q = require('Q')

You can locate the files while standing on your project directory using grep:

您可以使用 grep 站在项目目录中定位文件:

grep -HnrI "require('Q" *;

then, use any text editor to manually change the mentioned line to:

然后,使用任何文本编辑器将提到的行手动更改为:

Q = require('q')

Alternatively you can edit the related files on a more straight forward way by running the following command on your project directory:

或者,您可以通过在项目目录中运行以下命令以更直接的方式编辑相关文件:

grep -rl "require('Q" * | xargs sed -i "" "s/'Q'/'q'/g";

The single line above searches and edits the files that need the change.

上面的单行搜索和编辑需要更改的文件。

回答by Bradley Flood

Removing and then re-adding the platform again also works:

删除然后重新添加平台也有效:

cordova platform remove ios
cordova platform add ios

Now you can cordova build ios:)

现在你可以cordova build ios:)

As mentioned by MeV this was a bug.

正如 MeV 所提到的,这是一个错误。