I have Node installed via Homebrew. The path is /opt/homebrew/Cellar/node/21.1.0.
I've installed the Prettier Sublime Text plugin (JSPrettier) which requires the Node path to be defined. Defining it as /opt/homebrew/Cellar/node/21.1.0 gets it working.
However, whenever I update Node, the path changes.
How do I set this up so the Prettier Sublime Text plugin configuration and survive Node updates?
Manually updating the path works, but it's not very efficient.
When you install a package using homebrew, it puts a versioned copy in its "Cellar" and creates an unversioned link to it in its
bindirectory. That way, you just add thebindirectory to your PATH and your shell can always find the latest versions of every package you have installed - so you should generally avoid using specifically versioned executables.The locations of "Cellar" and
bindirectory differ according to the CPU architecture on a Mac:/opt/homebrew/Cellarand/opt/homebrew/bin/usr/local/Cellarand/usr/local/binYou can tell which one of the two locations it is using by running:
So, if you get a long listing of
/opt/homebrew/binfor thehtoppackage on Apple Silicon, you can see:which means there is an unversioned, plain
htopin/opt/homebrew/bin/htopwhich just points to the latest v3.2.2htopin the "Cellar".TL;DR
Use the unversioned links in
/usr/local/binoropt/homebrew/binunless you really, really need a specific version of anything.Note that if you are programmer/developer, the story is slightly more complicated. You will use "include files" (a.k.a. "header files") and libraries (e.g.
libxyz.so) andpkgconfigfiles (i.e. with.pcextension). These are linked in exactly the same way as executables, so you use:or
or, if you want your compilation/linking to work on either architecture: