添加android平台的phonegap时出错

时间:2014-11-13 00:28:07

标签: cordova phonegap-build

我正在尝试使用以下命令添加android平台

cordova platform add android

我看到以下输出:

Creating android project...

module.js:340
    throw err;
          ^
Error: Cannot find module 'which'
    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> (/Users/user1/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/lib/check_reqs.js:27: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: /Users/user1/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/create: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

我已经在我的bash_rc文件中设置了PATH

export PATH=${PATH}:/Users/user1/android-sdk-macosx/platform-tools:/Users/user1/android-sdk-macosx/platform-tools

我能够将iOS添加为平台。我已经更新到最新的Android SDK。

1 个答案:

答案 0 :(得分:0)

这是不正确的:

export PATH=${PATH}:/Users/user1/android-sdk-macosx/platform-tools:/Users/user1/android-sdk-macosx/platform-tools

应该是:

export PATH=/Users/user1/android-sdk-macosx/platform-tools:/Users/user1/android-sdk-macosx/tools:$PATH

您有platform-tools两次,缺少tools${PATH}应为$PATH