gpt4 book ai didi

node.js - antlr4-tool 在 Win10 中失败并显示 : Error: Command failed: which java

转载 作者:行者123 更新时间:2023-12-04 15:47:01 29 4
gpt4 key购买 nike

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

npm install --save-dev antlr4-tool

然:

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,运行时可以看到它的位置:

where java

但是因为我在 Windows 中,所以我不明白为什么命令是 which 而不是 where...

最佳答案

对于到达这里的任何人来说,这是一个错误,显然源于 Linux 和 Windows 之间的差异(Linux 中的 which 命令在 Windows 中是 where)。

要 W/A,仅当您在 Windows 中工作时,更改文件:

.../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

关于node.js - antlr4-tool 在 Win10 中失败并显示 : Error: Command failed: which java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55279276/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com