【问题标题】:phonegap won't install or work correctlyphonegap 无法安装或正常工作
【发布时间】:2014-10-10 09:00:39
【问题描述】:

安装 NodeJs 并运行 npm install -g phonegap 后,我得到的结果与应有的格式完全不同:

C:\Program Files\nodejs>npm install -g phonegap
|


> ws@0.4.31 install C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules
\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engi
ne.io\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

/
C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules\phonegap\node_modul
es\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\w
s>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild
-


> ws@0.4.31 install C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules
\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\sock
et.io-client\node_modules\engine.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

-
C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules\phonegap\node_modul
es\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_mo
dules\engine.io-client\node_modules\ws>node "C:\Program Files\nodejs\node_module
s\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
C:\Users\kyle David Krueger\AppData\Roaming\npm\phonegap -> C:\Users\kyle David
Krueger\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js
phonegap@3.5.0-0.21.14 C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modu
les\phonegap
├── pluralize@0.0.4
├── semver@1.1.0
├── colors@0.6.0-1
├── minimist@0.1.0
├── qrcode-terminal@0.9.4
├── shelljs@0.1.4
├── cordova@3.5.0-0.2.7 (q@0.9.7, underscore@1.4.4, nopt@2.2.1)
├── prompt@0.2.11 (revalidator@0.1.8, pkginfo@0.3.0, read@1.0.5, utile@0.2.1, wi
nston@0.6.2)
├── phonegap-build@0.8.4 (qrcode-terminal@0.8.0, shelljs@0.0.9, optimist@0.3.7,
phonegap-build-api@0.3.3)
├── connect-phonegap@0.12.8 (home-dir@0.1.2, connect-inject@0.3.2, shelljs@0.2.6
, request-progress@0.3.1, useragent@2.0.8, gaze@0.4.3, node-static@0.7.0, tar@0.
1.19, request@2.33.0, localtunnel@1.3.0, socket.io@1.0.6, connect@2.12.0)
└── cordova-lib@0.21.7 (osenv@0.0.3, properties-parser@0.2.3, mime@1.2.11, bplis
t-parser@0.0.5, q@0.9.7, semver@2.0.11, underscore@1.4.4, dep-graph@1.1.0, plist
-with-patches@0.5.1, npmconf@0.1.16, rc@0.3.0, xcode@0.6.6, elementtree@0.1.5, g
lob@3.2.11, tar@0.1.19, request@2.22.0, cordova-js@3.6.2, npm@1.3.4)

然而,这似乎可行,因为我可以创建新的 phonegap 项目,但这也有错误:

C:\Users\kyle David Krueger\workspace>phonegap create aoeu com.kdk.aoeu aoeu
[phonegap] missing library com.kdk.aoeu/www/3.5.0
[phonegap] downloading https://github.com/phonegap/phonegap-app-hello-world/arch
ive/3.5.0.tar.gz...
[phonegap] create called with the options C:\Users\kyle David Krueger\workspace\
aoeu com.kdk.aoeu aoeu
[phonegap] Customizing default config.xml file
[phonegap] created project at C:\Users\kyle David Krueger\workspace\aoeu

然后尝试运行 phonegap run android 会导致类似的情况似乎可以工作,但有错误

C:\Users\kyle David Krueger\workspace\aoeu>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...

C:\Users\kyle David Krueger\.cordova\lib\android\cordova\3.5.1\bin\node_modules\
q\q.js:126
                    throw e;
                          ^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
    at C:\Users\kyle David Krueger\.cordova\lib\android\cordova\3.5.1\bin\lib\ch
eck_reqs.js:47:27
    at ChildProcess.exithandler (child_process.js:652:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Socket.<anonymous> (child_process.js:969:11)
    at Socket.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)
{ [Error: cmd: Command failed with exit code 8] code: 8 }
   [error] cmd: Command failed with exit code 8

最后,打开 Eclipse 并尝试创建一个新项目会出现错误“parseSdkContent failed”。这实际上出现在您甚至选择要导入的文件之前,并且在从头开始创建全新的 android 应用程序时也会出现。 看起来这可能是由多个错误引起的,也可能是由一个错误引起的。

【问题讨论】:

  • 突出显示或提供有关您遇到的错误的一些详细信息

标签: android eclipse node.js cordova npm


【解决方案1】:

您需要从http://ant.apache.org/bindownload.cgi手动下载ant

然后在某处提取它。假设在驱动器D:\apache-ant-1.9.3

接下来添加环境变量ANT_HOME及其值D:\apache-ant-1.9.3

最后添加到路径变量%ANT_HOME%\bin

别忘了重启终端或命令提示符

【讨论】:

  • 我已经安装了 ANT JDK 和 ADT 并将它们全部添加到环境变量中,但我被告知要为所有它们使用 \bin 文件夹。我在没有 \bin 的情况下尝试了它,它做了同样的事情。
  • 另外,我发现不同的来源说将这些添加到路径系统变量和用户变量中;我最终将目录添加到两者中。
  • 在命令提示符ant -version 中写入,如果这没有显示 ant 版本,那么您的系统中的 ant 路径不正确。
  • 是的,我得到了这个 C:\>ant -version 'ant' 不是内部或外部命令、可运行程序或批处理文件。
  • 所有环境变量应该是什么样的?我和他们玩了一会儿,让 cmd 告诉我 ANT_HOME 设置不正确,我想这是朝着正确方向迈出的一步。有 JAVA_HOME、ANT_HOME、PATH 用户变量和 Path 环境变量。它们应该是什么?
猜你喜欢
  • 2019-10-19
  • 2012-01-23
  • 1970-01-01
  • 2012-08-19
  • 1970-01-01
  • 2020-10-26
  • 2011-12-18
  • 1970-01-01
  • 2017-10-05
相关资源
最近更新 更多