Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fnm doesn’t automatically change versions with .node-version or .nvmrc files #433

Closed
drwpow opened this issue Apr 15, 2021 · 9 comments
Closed

Comments

@drwpow
Copy link

drwpow commented Apr 15, 2021

OS: Latest macOS (v11.2.3 Big Sur)

Not sure if this is an issue within this project, or my current setup. fnm does seem to be managing my Node version (which node shows an fnm location). If I use fnm default or fnm use it respects that. But when I cd into a dir with .node-version or .nvmrc, the Node version doesn’t seem to change.

What’s weird is that if I’m in a dir with a .node-version or .nvmrc file, running fnm install will correctly read that file (warning: Version already installed etc.). However, running node --version always shows the default. Am I missing something in setup?

@drwpow
Copy link
Author

drwpow commented Apr 15, 2021

Actually, I might just be misunderstanding the usage of this library. I think I was expecting nodenv-like behavior with automatic switching. But I think fnm use is required each time?

@ljharb
Copy link

ljharb commented Apr 15, 2021

nvm-like behavior has no automatic switching, which i believe is what fnm is largely emulating.

@drwpow drwpow changed the title fnm doesn’t respect .node-version or .nvmrc files fnm doesn’t automatically change versions with .node-version or .nvmrc files Apr 15, 2021
@Schniz
Copy link
Owner

Schniz commented Apr 15, 2021

You can use --use-on-cd in your fnm env call to generate the automatic switching script for your shell ✌️

Check it in the README, I'm afk and can not link right now 😃

@Schniz Schniz closed this as completed Apr 15, 2021
@Mugilan-Codes
Copy link

You can use --use-on-cd in your fnm env call to generate the automatic switching script for your shell ✌️

Check it in the README, I'm afk and can not link right now 😃

This works but when I get back to a parent directory or exit from the folder, it stays in the changed node version instead of reverting back to global default. Is there any workaround for this?

@olrtg
Copy link

olrtg commented Mar 21, 2022

I'm also interested in a possible workaround for this issue 👍🏼

@wight554
Copy link

wight554 commented Apr 26, 2022

You can use --use-on-cd in your fnm env call to generate the automatic switching script for your shell ✌️
Check it in the README, I'm afk and can not link right now 😃

This works but when I get back to a parent directory or exit from the folder, it stays in the changed node version instead of reverting back to global default. Is there any workaround for this?

Have you managed to find solution?

@sberlan-odeko
Copy link

sberlan-odeko commented Jun 20, 2023

In case someone lands on this ticket from search engines, for it to automatically switch to default alias when .node-version and .nvmrc are not found in parent folders, you want to use --use-on-cd --version-file-strategy recursive instead of just --use-on-cd.

@Mugilan-Codes
Copy link

You can use --use-on-cd in your fnm env call to generate the automatic switching script for your shell ✌️
Check it in the README, I'm afk and can not link right now 😃

This works but when I get back to a parent directory or exit from the folder, it stays in the changed node version instead of reverting back to global default. Is there any workaround for this?

This is referred in #964, this works just like @sberlan-odeko as stated in here

@webelin
Copy link

webelin commented Nov 14, 2023

In case someone lands on this ticket from search engines, for it to automatically switch to default alias when .node-version and .nvmrc are not found in parent folders, you want to use --use-on-cd --version-file-strategy recursive instead of just --use-on-cd.

I experience a lot of output from fnm, whenever type a command. I solved that by adding > /dev/null and therefore suppressing the noise caused by the command in the config file:

fnm env --use-on-cd | source > /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants