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
But received:
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)
I have Java install, and I can see its location when running:
where java
But since I'm in Windows, I don't understand why the command is which and not where...
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).
To W/A it, only if you work in Windows, change the file:
.../node_modules/antlr4-tool/dist/antlr-core/antlr-compiler.js, line #98, from:
child.execSync('which java');
to:
child.execSync('where java');
See https://github.com/mcchatman8009/antlr4-tool/issues/21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With