错误:执行命令'ant' – 安装并设置ANT_HOME后

经过我的环境variables摔跤得到正确的目录设置,我现在可以得到的版本:

C:\Projects\TestProj>ant -version Apache Ant(TM) version 1.8.4 compiled on May 22 2012 

ant似乎在工作:

 C:\Projects\TestProj>ant Buildfile: build.xml does not exist! Build failed 

我尝试时仍然遇到错误:

 C:\Projects\TestProj>cordova -d platform add android cordova library for "android" already exists. No need to download. Continuing. Checking if platform "android" passes minimum requirements... Creating android project... Running command: C:\Users\Administrator\.cordova\lib\android\cordova\3.4.0\bin\c reate.bat --cli C:\Projects\TestProj\platforms\android com.company.testproj TestProj C:\Users\Administrator\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\qj s:126 throw e; ^ Error: ERROR : executing command 'ant', make sure you have ant installed and add ed to your path. 

从我读过的所有post看,这是ANT_HOME的一个问题,但似乎我已经解决了这一部分。 编辑我已经安装了ant 1.9.3程序文件,并驻留在: 编辑改变只是ant,而不是apache-ant-1.9.3-bin \ apache-ant-1.9.3

 C:\Program Files\ant 

回声家:

 C:\Projects\TestProj>echo %ANT_HOME% C:\Program Files\ant 

当然,我的path中有%ANT_HOME%\ bin。 任何帮助确定问题将不胜感激。

我认为你用于ANT_HOME的path是错误的。 C:\Users\Administrator\AppData\Roaming\npm\node_modules\ant\ant似乎是ant npm模块的path,而不是ant命令。

Ant命令更可能是程序文件中的某处。 在一个cmd中,运行where ant ,知道你的pathantfind了什么地方,然后使用这个pathANT_HOME。 (在文件夹中你应该看到ant,ant.cmd和ant.bat)

经过进一步调查,我认为你的问题是造成一半cordova由于您的计算机(cmd autorun参数)中的registry设置不正确检查节点错误和一半。

您可以在这些post中查看答案以获取更多信息:

  • nodejs child_process exec'java -version'
  • Windows CMD.exe“系统找不到指定的path”。

检查您是否有registry项HKCU\Software\Microsoft\Command Processor\AutoRun

设置variables后,重新启动您的机器。 closures命令提示符等将无济于事。 即使我被困了很长一段时间,第二天,当我开始我的系统,它工作正常:P