在与环境变量进行斗争以获取正确的目录集之后,我现在可以获得以下版本:
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\q.j
s:126
throw e;
^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
从我读过的所有帖子来看,这是 ANT_HOME 的问题,但看来我已经解决了这部分问题。 编辑 我已将 ant 1.9.3 安装到程序文件中,bin 位于: 编辑更改为 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
当然,我的路径中有 %ANT_HOME%\bin 。任何确定问题的帮助将不胜感激。
最佳答案
我认为您使用的 ANT_HOME 路径是错误的。 C:\Users\Administrator\AppData\Roaming\npm\node_modules\ant\ant
似乎是 ant npm module 的路径但不是 ant 命令。
Ant 命令更可能位于程序文件中的某个位置。在 cmd 中,运行 where ant
以了解在路径中的何处找到 ant,并将该路径用作 ANT_HOME。 (在该文件夹中您应该看到 ant、ant.cmd 和 ant.bat)
经过进一步调查,我认为您的问题一半是由于 cordova 没有正确检查 Node 错误引起的,一半是由于计算机中的注册表设置(cmd 自动运行参数)引起的。
您可以查看这些帖子中的答案以获取更多信息:
- nodejs child_process exec 'java -version'
- Windows CMD.exe "The system cannot find the path specified."
检查您是否有注册表项HKCU\Software\Microsoft\Command Processor\AutoRun
关于node.js - 错误: executing command 'ant' - After installation and setting ANT_HOME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23063605/