peggyjs / peggy

Peggy: Parser generator for JavaScript
https://peggyjs.org/
MIT License
906 stars 64 forks source link

correct documentation #478

Closed johndeighan closed 6 months ago

johndeighan commented 6 months ago

Reading the documentation at https://peggyjs.org/documentation.html#using-the-parser:

It gives the example:

$ peggy arithmetics.pegjs

However, there are 2 ways to install an npm module - either globally, using npm install -g or locally, using npm install or npm install -D. This page (earlier) recommends installing locally, to which I agree. But when you do that, you have to use npx peggy... to run from the command line, so this example fails. There is, I admit, an earlier example of getting help that does use npx. Also, the earlier example of setting up a script key in your package.json file works, even though it doesn't use npx. This is some kind of magic that I do not approve of. What I'm saying is that I'd prefer if it used npx just so that users aren't tempted to run the command as presented from the command line, which would fail. Just my 2 cents.

BTW, I'm on Windows 11 and use the git bash shell, so maybe other shells would find the peggy command from the command shell without using npx - I just don't know. But I would get the message "bash: peggy: command not found"

hildjj commented 6 months ago

I'll add npx to the examples. Why it works in package.json is that npm adds node_modules/.bin to your path automatically, on all platforms. Not using npx in your package.json file is idiomatic nodejs.