Cordova 4.3.0 - 构建命令返回错误无法找到模块' Q'

时间:2015-03-06 11:40:00

标签: xcode cordova npm node-modules cordova-cli

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

cordova build

返回以下错误:

    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)

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

我试图跑:

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

但没有任何改变。

有任何帮助吗? 非常感谢你

3 个答案:

答案 0 :(得分:7)

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

Apache Cordova ios - Git Repository

答案 1 :(得分:1)

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

到目前为止,为了解决这个问题,你必须找到包含这样一行的文件:

 Q = require('Q')

您可以使用grep:

找到站在项目目录中的文件
grep -HnrI "require('Q" *;

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

Q = require('q')

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

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

上面的一行搜索并编辑需要更改的文件。

答案 2 :(得分:0)

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

cordova platform remove ios
cordova platform add ios

现在你可以cordova build ios:)

正如MeV所说,这是一个错误。

相关问题