-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
How to install global npm tools that are available across all node versions #109
Comments
It’s a very very bad idea to share global installs across node versions, and it won’t even work most of the time due to incompatibilities across node versions. |
So I guess the best idea is to make sure to install things on I don't want to install tools 2 or 3 times for each node version. :( |
In general I’d recommend not installing anything globally anyways - everything should be installed locally per project. |
I agree with @ljharb - I don't use global installations and I'm okay with it. When I really want to make something global, I have a I thought about making a different binary, and providing something like |
If you need any help, ping me on the Twitter, Reason Discord, Email, whatever! I'd be happy to help 😄 |
If I install my global packages under And if I do run it again and supposedly latest node version will be upgraded, I still keep all my global npm tools? ( |
fnm doesn't store
I think you better off have a |
How do I then install stuff to it with |
Also for some reason all my globally installed packages now live here:
i.e. I didn't change anything. I would expect them to live under |
Also this fails: ~/.fnm
❯ fnm ls
The following versions are installed:
* system
* v10.15.0 (default)
* latest
~/.fnm
❯ fnm default latest
fnm: unknown command `default'.
Usage: fnm COMMAND ...
Try `fnm --help' for more information.
~/.fnm
❯ fnm --version
1.11.0
~/.fnm
❯ Although I believe default option should already be in 1.11. |
I also don't get how or why |
This is how fnm works with multiple shells (
You don't, you install in that specific directory. This is easier to understand and maintain over global installations which always feel clunky and problematic. You can make a bash function like:
I just released 1.12 which has this feature 😄 |
can you update brew formula too? :) |
This is very handy, thanks |
Is it possible to uninstall things from this directory via And is it possible to make |
I probably did not read enough but can someone point to me how to automate the reinstallation of npm packages in an automated fashion or point me to the answer is it is stated above and I missed it ??? |
This suits my needs:
From: https://docs.npmjs.com/cli/v9/commands/npm-update#updating-globally-installed-packages |
I also try to avoid global packages. However, some packages are tools/utils I need anywhere in my shell like those ones (
How do you manage (install or update) those global packages depending on the node version you use in your shell? Let's say the latest for any shell and the specific version for any node/frontend project? Do I need to install them again for each node version? |
If I understood well: When you install a global package while using a specific version of Node.js with fnm, the package is installed in a directory associated with that specific version. If you install a global package while using the system version of Node.js, it will be accessible from any version of Node.js that you use with fnm. This can have advantages in terms of simplicity, it may also introduce risks if the different Node.js versions are not compatible with the package. In summary, if you want global packages to be tied to a specific version of Node.js, you should install them while that version is active with fnm. If you want them to be available across all versions, you can install them using the system version of Node.js. |
There's no reason not to install global npm packages. Any project that relies on a specific version of the package should be specifying that in the package.json, along with the node version etc |
There are definitely some little helper commands I write for Node that I want to be on my PATH so I can run them anywhere. Not tool like prettier that would be a bad idea to install globally, just helper commands I use that run manually to accomplish various things. It would be great to have some tool that simplifies picking/installing a compatible version of Node for such commands and running them with that version, even if I've activated a different version in my current shell session. There are probably ways I could manage that with my own bin scripts, but if a tool like nvm or fnm provided a helper for it, it would be awesome. It's up to users to know when it's wise to install a command globally versus within a specific project. |
Volta supports this https://docs.volta.sh/guide/understanding#managing-your-toolchain |
there are lots of reasons to install global packages, most of them are CLI's. e.g. https://www.npmjs.com/package/yalc and so on. |
Say I ran
npm install --global prettier
It gets installed into Users/nikivi/.fnm/node-versions/latest/installation/lib since I am currently using
latest
version of node (fnm use latest
).But if I fnm use v10.15.0 and run
npm list -g --depth 0
. I dont get any packages. This is very annoying.Is it possible to make it so that all globally installed packages I have are available to me no matter what node version I use?
The text was updated successfully, but these errors were encountered: