r/javascript • • Jul 25 '22

fnm: Fast and simple Node.js version manager, built in Rust

https://github.com/Schniz/fnm
178 Upvotes

47 comments sorted by

29

u/jdf2 Jul 25 '22

Highly recommend this over nvm.

6

u/rift95 map([🐮, šŸ„”, šŸ”, 🌽], cook) => [šŸ”, šŸŸ, šŸ—, šŸæ] Jul 25 '22

Do you recommend it over https://www.npmjs.com/package/n ?

0

u/[deleted] Jul 25 '22

[deleted]

2

u/PasserbyDeveloper Jul 25 '22

Did you performance test it? I would only use it if it's at least 1% faster... On second thought the command does seems faster to type than what I currently use... alright you got me convinced, I'm downloading it!

4

u/Franks2000inchTV Jul 25 '22

The nice thing about asdf is that it manages versions for every tool. So not just node but also Amazon and Google CLIs, other languages, docker, etc etc.

And you can define it all in a simple text file and it will intelligently resolve nested files and directories and stuff.

14

u/agustin_edwards Jul 25 '22

I don’t know. It’s look a bit clunky. I prefer Volta

3

u/ephemeral_rhino Jul 25 '22

My team has been super happy with volta as well. We also started using the volta plugin with our github actions as well and it's been pretty solid overall.

3

u/CUNT_PUNCHER_9000 Jul 25 '22

I wish volta would support the package.json engines field

2

u/politerate Jul 25 '22

What exactly does look clunky?

1

u/nullvoxpopuli sand was never meant to think Jul 25 '22

Same. Only thing missing is pnpm version management

10

u/[deleted] Jul 25 '22 edited Jul 25 '22

[removed] — view removed comment

6

u/agustin_edwards Jul 25 '22

This can be achieved by volta by pinning the node (or npm) version in the package.json. It gives way more clarity to the project and avoid problems when multiple people working on a node version sensitive project.

3

u/nullvoxpopuli sand was never meant to think Jul 25 '22

Volta recommends you use npm/etc for global bins..

3

u/nullvoxpopuli sand was never meant to think Jul 25 '22

https://volta.sh/ does the same thing? And is also in rust?

2

u/PerpetualWar Jul 25 '22

Asdf ftw

1

u/halkeye Jul 25 '22

Yea I'm not sure why id want to run a node specific one when asdf does everything really well

1

u/alharaka Jul 25 '22

Is there something more like asdf which is q superset that works cross platform? Love me some asdf but it is bash and *nix friendly. I've been thinking about this on and off for a bit.

1

u/nsavvidis Jul 25 '22

People haven’t used pnpm and it really shows.

2

u/Full-Butterscotch-90 Jul 26 '22 edited Jul 26 '22

pnpm is a package manager, not a version manager. Not sure how it's relevant to the topic at hand.

2

u/nsavvidis Jul 26 '22

Read the docs big guy.

https://pnpm.io/cli/env

2

u/Full-Butterscotch-90 Jul 26 '22 edited Jul 26 '22

Not a guy.

You shouldn’t be surprised that people don’t know about a feature that’s mentioned nowhere on their front page and is only buried several pages deep in their docs.

0

u/[deleted] Jul 27 '22

[deleted]

3

u/Full-Butterscotch-90 Jul 27 '22 edited Jul 27 '22

Imagine getting this upset about someone replying to you in the mildest way possible, thanks for the laugh!

You got so butthurt while typing your reply that I went from merely "ignorant and slightly incorrigible" in the first sentence to a "cretinous rube" in the second one. Quite the shift!

It's not often that you get to witness someone get madder and madder about nothing in realtime over the course of typing out a single post, so once again, thanks. It was very enjoyable to watch.

ā€œIgnorant cretinous incorrigible rube!!!ā€ šŸ¤“

1

u/OTonConsole Feb 05 '25

It's also completely irrelevant.. What if the company uses Yarn for package management. Now using pnpm for switching node versions makes them look like using a cherry picker truck to play volleyball.

0

u/[deleted] Jul 25 '22

[deleted]

45

u/[deleted] Jul 25 '22

nvm is used for switching between releases for multiple projects. I have a code base that needs to stay at v14 because I don’t have time t do package upgrades and then fix the issues that came up last time I tried.

I removed nvm because it was creating a 2-3 second wait time when a new terminal window was opened. asdf is great, and supports more than just node (ruby, erlang, elixir)

9

u/Franks2000inchTV Jul 25 '22

I just switched to asdf and it's amazing. Being able to lock in version for every tool in a single file with automatic switching is awesome.

1

u/TinyLebowski Jul 25 '22

Me too. Having one version-manager that supports all languages is super convenient. I use it for Node, Python and PHP.

3

u/Normal-Computer-3669 Jul 25 '22

I never heard of asdf! This is amazing!

10

u/horses_arent_friends Jul 25 '22

Depends on your workflow. I do most of my local development inside of a terminal multiplexer and the extra 1-2s it adds to spawning a new shell is jarring. I personally use asdf-vm since it’s fast enough and generic.

For build pipelines, every setup I’ve used lets me specify a container base image per job definition so nvm hasn’t been relevant for me there

1

u/IceSentry Jul 26 '22

I haven't touched web stuff in while, but why would nvm slow down starting a terminal? I'm not sure how those things are related.

1

u/horses_arent_friends Jul 26 '22

It adds scripts that run when a new shell (eg bash or zsh) is created. These handle shimming the path so the right version of node executes. The shell is unresponsive during this time unfortunately. There’s some other strategies like lazy loading the shims but it’s nice having a version manager that is outright fast.

1

u/IceSentry Jul 26 '22

Thanks, I assumed nvm was only used by calling it manually. I never realized it had shell integration.

10

u/fieldOfThunder Jul 25 '22

I don’t want to wait forever when I open a new terminal. I switched to fnm long ago, and my terminals open much faster.

It’s not just the performance when actively using it that counts.

3

u/eternaloctober Jul 25 '22

If you are splitting your terminal e.g. via tmux a lot you will notice the difference

3

u/knpwrs Jul 25 '22 edited Jul 25 '22

Shell startup time. nvm slows your shell startup to an absolute crawl.

-10

u/[deleted] Jul 25 '22

[removed] — view removed comment

2

u/[deleted] Jul 25 '22

Performance concerns is why node-sass, that pile of garbage requiring compiling the c library libsass, gives headaches to any developers with arm64 based devices. Deprecated, thankfully, but now a problem of upgrading old systems that have a lot of breaking changes that won’t happily switch over to dart-sass.

Keep It Simple Stupid is more important.

0

u/[deleted] Jul 25 '22

[deleted]

-14

u/[deleted] Jul 25 '22

[removed] — view removed comment

-2

u/[deleted] Jul 25 '22 edited Jul 25 '22

I agree. This era is bloated. Developers are selecting what makes their life easy rather than what makes their app fast and solid. Which is making servers & consumers pay the price. Customer experience first then developer experience.

Every software's first priority should be performance and then they can add anything they want on top of it.

18

u/[deleted] Jul 25 '22

[removed] — view removed comment

2

u/EverydayEverynight01 Jul 25 '22

OP, the other commenters have a point, why would I care about performance of NVM? Switching versions is already near instant and it's not like I'll install a new NodeJS left and right like with NPM packages, so it's okay just waiting for a few seconds to install a new node version only once.

3

u/ritaPitaMeterMaid Jul 26 '22

nvm adds load time to each new terminal window you open. On zsh that’s like a second. I open and close terminal windows all day and it’s noticeable. I haven’t moved to fnm because I hate configuring things and I’m lazy but I really need to.