Closed mjambon closed 3 years ago
@mjambon Since the tree-sitter
executable itself is now a binary (rather than something that depends on a JS env), I can’t see a downside to installing one globally, as it’s easy to upgrade (or if you're building it locally) with a cp
into /usr/local/bin
. I don’t think we can provide a more convenient way than that, though you could always install a shell alias mapping to ../node_modules/.bin/tree-sitter
. I’m going to close this, but feel free to reopen it or just leave a commentif you have further questions.
Echoing @patrickt, if you're not making changes to the CLI itself, you could definitely install it globally. Depending on your platform, the CLI might also be available in your system package manager. (I'm on Arch Linux, for instance, and I typically use sudo pacman -S tree-sitter
to get a stock install of the CLI and runtime library.)
That said, npx
should still work, I think... I was just able to use it in a fresh checkout of dcreager/tree-sitter-test:
$ npm --version
7.11.1
$ npx --version
7.11.1
$ git clone https://github.com/dcreager/tree-sitter-test
$ npm install
$ ls -l node_modules/.bin
total 0
lrwxrwxrwx 1 dcreager dcreager 25 Apr 26 13:45 tree-sitter -> ../tree-sitter-cli/cli.js*
$ npx tree-sitter --version
tree-sitter 0.19.4 (6dd41e2e45f8b4a00fda21f28bc0ebc6b172ffed)
Thanks @patrickt and @dcreager! I'll use a global install.
I used to do this:
But I'm no longer able to run
tree-sitter
directly from the command line. I can do this and it works fine:But I don't know what to do to parse a snippet without adding to the test corpus.
npx
, whose job is to locate executables installed locally, can't findtree-sitter
when running from a subfolder. Here's what I do:(I'm using npm version 7.5.3 and npx version 10.2.2).
Calling the
tree-sitter
installed under<root>/node_modules/.bin/
appears to work, but it's cumbersome.Is there a convenient way to use the project-local
tree-sitter
command or is it more practical to use a globally-installedtree-sitter
?