fnm icon indicating copy to clipboard operation
fnm copied to clipboard

Doesn't set the node version across the shell?

Open Jaxenormus opened this issue 4 years ago • 4 comments

https://user-images.githubusercontent.com/40841758/104665976-be284b80-56a0-11eb-8d76-06728b24049a.mov

Video will show what I mean, switching to nvm.fish in the time being

Jaxenormus avatar Jan 15 '21 00:01 Jaxenormus

Looks like you have no default node version. That’s weird. Can be fixed with fnm default 14 😄 Every shell has its own node setting so you can have multiple projects with different node versions

Schniz avatar Jan 15 '21 07:01 Schniz

Looks like you have no default node version. That’s weird. Can be fixed with fnm default 14 😄 Every shell has its own node setting so you can have multiple projects with different node versions

I can imagine that that works for certain usecases, but I don't always want a new shell to fall back to the default.

For example, my default node version is 14. When I'm working on a new project that requires node 10, but doesn't have an .nvmrc (maybe I don't have permission to add that to the project for example), I have to keep switching to node 10 for every new shell I'm opening.

It would be nice if there was a way to persist the selected version, until a new call to fnm use is made. Say like fnm use 10 --persist, or something of that nature.

ismay avatar Apr 08 '21 13:04 ismay

You can use fnm env --use-on-cd and it will make sure your shell is updated based on .node-version or .nvmrc files.

Regarding fnm use 10 --persist, sounds like it can set the default version, if we had fnm use 10 --mark-as-default, which is something I was thinking on adding (both to fnm use and fnm install)

Schniz avatar Apr 08 '21 15:04 Schniz

You can use fnm env --use-on-cd and it will make sure your shell is updated based on .node-version or .nvmrc files.

I understand, but say you're working on a project that doesn't have an .nvmrc or .node-version, where you don't want to use the default node version? I guess then that the solution would be to use fnm default to set it to the version you want to use in that project?

So basically, with the current behaviour fnm use <version> is per-shell, and fnm default <version> is persistent, right?

Personally I would expect fnm use <version> to persist the selected version, and fnm default <version> to set the version that gets selected when you execute fnm use without an explicit version (and when it can't find an nvmrc or node-version). To me personally the latter would seem more convenient/intuitive.

ismay avatar Apr 08 '21 15:04 ismay