Win10中的antlr4-tool失败,错误:错误:命令失败:哪个Java [英] antlr4-tool fails in Win10 with: Error: Command failed: which java

查看:111
本文介绍了Win10中的antlr4-tool失败,错误:错误:命令失败:哪个Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Win10中运行,试图在Node.JS中创建解析器,我安装了ANTLR4工具:

Running in Win10, in an attempt to create a parser in Node.JS, I installed ANTLR4 tool:

npm install --save-dev antlr4-tool

Ran:

c:/prj/parser/node_modules/.bin/antlr4-tool.cmd -o parser grammar/Lang.g4

但是收到了:

Compiling grammar/Lang.g4...
'which' is not recognized as an internal or external command,
operable program or batch file.
child_process.js:677
    throw err;
    ^

Error: Command failed: which java
'which' is not recognized as an internal or external command,
operable program or batch file.

    at checkExecSyncError (child_process.js:637:11)
    at Object.execSync (child_process.js:674:13)
    at c:\prj\parser\node_modules\antlr4-tool\dist\antlr-core\antlr-compiler.js:98:19
    at chdir (c:\prj\parser\node_modules\chdir\index.js:6:13)
    at AntlrCompiler.compileJavaScript (c:\prj\parser\node_modules\antlr4-tool\dist\antlr-core\antlr-compiler.js:97:9)
    at AntlrCompiler.compileTypeScript (c:\prj\parser\node_modules\antlr4-tool\dist\antlr-core\antlr-compiler.js:62:38)
    at c:\prj\parser\node_modules\antlr4-tool\dist\antlr-core\index.js:40:78
    at c:\prj\parser\node_modules\antlr4-tool\dist\antlr-core\index.js:17:23
    at arrayEach (c:\prj\parser\node_modules\lodash\lodash.js:516:11)
    at Function.forEach (c:\prj\parser\node_modules\lodash\lodash.js:9344:14)

我已经安装了Java,并且在运行时可以看到其位置:

I have Java install, and I can see its location when running:

where java

但是由于我在Windows中,所以我不明白为什么命令是哪个而不是 where ...

But since I'm in Windows, I don't understand why the command is which and not where...

推荐答案

对于到达这里的人来说,这是一个错误,显然是源于Linux和Windows之间的差异( Linux中的命令为在Windows中的位置.

To whomever gets here, it's a bug, apprently stemming from the difference between Linux and Windows (which command in Linux is where in Windows).

要使用它, 仅在Windows中工作 ,更改文件:

To W/A it, only if you work in Windows, change the file:

.../node_modules/antlr4-tool/dist/antlr-core/antlr-compiler.js ,第98行,来自:

child.execSync('which java');

收件人:

child.execSync('where java');

请参见 https://github.com/mcchatman8009/antlr4-tool/issues/21

这篇关于Win10中的antlr4-tool失败,错误:错误:命令失败:哪个Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆