14

I really just need something I can check into version control to declare a Node version, and swap out the Node version in someone's shell while they're in that directory.

.nvmrc is supposed to do this but there's no official support for Fish and workarounds are junk.

This doesn't seem terribly complicated. Is there anything new/hawt to replace nvm?

corysimmons
  • 7,296
  • 4
  • 57
  • 65
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. You **might** try your luck at [softwarereqs](https://softwarerecs.stackexchange.com) - but **first** study the corresponding help center to enable yourself to understand the policies of that community . And consider deleting *this* question please! Thanks! – GhostCat Nov 27 '17 at 13:23

5 Answers5

10

I use Fish shell, so https://github.com/fisherman/fnm is really nice. In lieu of all those features, https://github.com/tj/n is simple and works everywhere.

corysimmons
  • 7,296
  • 4
  • 57
  • 65
  • 2
    `n` does not work on Windows and neither does `fnm` – Andria Jul 01 '20 at 22:50
  • 8
    I don't want to come across as a jerk, but if you're a developer for anything other than Microsoft-specific stuff or video games, I'd highly suggest you install VirtualBox + a copy of Ubuntu and force-feed yourself Linux. Half of common developer tools just don't work on Windows without a lot of hacky workarounds. In lieu of that, I'd suggest looking into https://github.com/asdf-vm/asdf — I haven't yet, but it looks better than alternatives... But tbh, I've been happily using `n` for years now. – corysimmons Jul 02 '20 at 02:07
  • @corysimmons, "*nix & variants" really is not "everywhere". Not jerky, just a very inaccurate statement. – spechter Aug 19 '22 at 11:28
9

I use volta as replacement. It doesn't use the .nvmrc but a configuration in the package.json.

It's a great solution in my eyes because it uses shims, so it is completely independent of the shell you use. It doesn't has to be integrated in there. Instead of a normal node installation you (or the installation) puts volta in the PATH variable of your OS. So you are using node, npm, yarn, ... normally, but internally it's calling volta and volta checks your package.json and uses the node/yarn/... version configured there, or the global version if there is no volta configuration. So if you switch a project with cd ../xyz volta also changes the node version or installs it if it is missing without the need to run a command or something. So no nvm use or fnm use necessary.

Except from IntelliJ-Issue WEB-44867 (that requires a bit of manual extra configuration) it works perfectly for me.

Nico
  • 185
  • 2
  • 7
7

I know this is an old question and this popped up in my search first.

fnm, https://github.com/Schniz/fnm seems to be a good alternative build in Rust. It is and very fast when compared to nvm.

6

I use https://github.com/tj/n (Node.js version management: no subshells, no profile setup, no convoluted API, just simple)

Arun Gopalpuri
  • 2,340
  • 26
  • 27
  • This one of the best node version management tool... one day actually i accidentally stumbled on it and it worked great – Vaisakh K M Jan 21 '23 at 16:49
3

you can use avn-nvm. It uses nvm to manage the Node version, and avn will trigger the switch to the right version for you when you enter the directory. That's what we use in my team.

ChrisR
  • 3,922
  • 1
  • 14
  • 24