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

最后都变了- 提交于 2019-12-09 06:07:43

问题


After updating cordova to version 4.3.0 the command:

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.

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


回答1:


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

Apache Cordova ios - Git Repository




回答2:


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

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 -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.




回答3:


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

cordova platform remove ios
cordova platform add ios

Now you can cordova build ios :)

As mentioned by MeV this was a bug.



来源:https://stackoverflow.com/questions/28898012/cordova-4-3-0-build-command-returns-error-cannot-find-module-q

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!