Coder Social home page Coder Social logo

Comments (30)

VincentCordobes avatar VincentCordobes commented on June 19, 2024 7

Same for me when switching node version via fnm use. I need to eval "$(fnm env --multi)" to apply it

Note that I use fnm 1.11.0

from fnm.

Vinlock avatar Vinlock commented on June 19, 2024 3

Nevermind 🤦🏼 . I guess I had to restart iTerm as even though I had done source ~/.zshrc.

It's working great now, and wow it's incredibly faster than nvm 😮 .

➜ node -v
v15.14.0

➜ fnm use 10
Using Node v10.24.1

➜ node -v
v10.24.1

Thanks for your time!

from fnm.

Schniz avatar Schniz commented on June 19, 2024 2

Ohhh, that looks like a common issue. I wonder if we can implement a fnm doctor command that will search in your PATH for node before FNM and alert for that, and maybe also provide the output for the commands above 😄

from fnm.

perkrlsn avatar perkrlsn commented on June 19, 2024 2

I have the same issue, but I refuse going back to nvm because it's just so slow and I love the speed of fnm :)

I ended up doing something like this (since I'm not very good at bash/zsh), rehashing on each fnm use seems to solve it.

#FNM
eval "`fnm env --multi`"

#FNM autoload
autoload -U add-zsh-hook
    _fnm_autoload_hook () {
        if [[ -f .node-version && -r .node-version ]]; then
	    echo "fnm: Found .node-version"
	    fnm use
	    rehash
        elif [[ -f .nvmrc && -r .nvmrc ]]; then
	    echo "fnm: Found .nvmrc"
	    fnm use
	    rehash
        else
	    fnm use system --quiet
	    rehash
	fi
    }

add-zsh-hook chpwd _fnm_autoload_hook && _fnm_autoload_hook

from fnm.

Schniz avatar Schniz commented on June 19, 2024 1

Sorry about that. can you run the following commands and report the output?

echo "PATH=$PATH"
env | grep FNM_
echo "node in $(which node)"
echo "find:"
find $FNM_DIR -maxdepth 2

from fnm.

cem2ran avatar cem2ran commented on June 19, 2024 1

That was pretty helpful actually! I realized the issue is because linuxbrew inserted its init script in ~/.profile, which loads bashrc followed by linuxbrew init. Node was initially installed via linuxbrew, which then became the default no matter what I did with fnm.

from fnm.

Vinlock avatar Vinlock commented on June 19, 2024 1

@Schniz thanks for the reply!

I'm running zsh and I added

# FNM
eval "$(fnm env)"

to my ~/.zshrc file.

After sourcing the ~.zshrc file. I do the following with the following result:

➜ fnm use 10
Using Node v10.24.1

➜ node -v
v15.14.0

Did I miss something?

from fnm.

timodempwolf avatar timodempwolf commented on June 19, 2024 1

I am still facing this issue. I have to use rehash to make this version stick.

╭─timod@cw-laptop ~ 
╰─$ node --version
v16.16.0
╭─timod@cw-laptop ~ 
╰─$ fnm use 18
Using Node v18.6.0
╭─timod@cw-laptop ~ 
╰─$ node --version
v16.16.0
╭─timod@cw-laptop ~ 
╰─$ fnm --version
fnm 1.31.0
╭─timod@cw-laptop ~ 
╰─$ rehash
╭─timod@cw-laptop ~ 
╰─$ node --version
v18.6.0

from fnm.

a-shtubov avatar a-shtubov commented on June 19, 2024 1

I ran into the same problem. Every node version switch required rehash in my zsh shell. Turned out the problem was that no default node version was set in fnm. Once I ran fnm default x.x.x versions started switching correctly

from fnm.

therosbif avatar therosbif commented on June 19, 2024 1

For anyone having an issue with fnm conflicting with homebrew's installation of node on fish I fixed it by moving the following line from ~/.config/fish/config.fish to ~/.config/fish/conf.d/brew.fish:

# ~/.config/fish/conf.d/brew.fish
export PATH="/opt/homebrew/sbin:/opt/homebrew/bin:$PATH"

from fnm.

Schniz avatar Schniz commented on June 19, 2024

Hey! Can you please try 1.9.1 and see if it fixes that?

from fnm.

davidosomething avatar davidosomething commented on June 19, 2024

The path is updated if you do echo $PATH but in zsh I had to do a rehash after every switch to get it to actually use that path

from fnm.

Schniz avatar Schniz commented on June 19, 2024

It is very weird, and I'm very sorry it happens to you.
I just tried it on a new installation in Fish and it does work. Are you sure that's the problem? can you please record it with asciinema so we'll see what's going on?

from fnm.

Schniz avatar Schniz commented on June 19, 2024

Can you show me a shell that runs the following?

fnm env --multi | source

echo "-> NODE: "(which node)
echo "-> VER: "(node -v)
echo "-> PATH: $PATH"
env | grep FNM

fnm ls
fnm use <YOUR VERSION HERE>

echo "-> NODE: "(which node)
echo "-> VER: "(node -v)
echo "-> PATH: $PATH"
env | grep FNM

I can't get it to fail on my machine - but maybe this will help me 😄

from fnm.

Schniz avatar Schniz commented on June 19, 2024

I hope I got the fish syntax right!

from fnm.

VincentCordobes avatar VincentCordobes commented on June 19, 2024

Ok that's weird, I didn't change anything and now it is working as expected (btw I am using zsh) @Schniz

from fnm.

dncrews avatar dncrews commented on June 19, 2024

I had the same problem using fnm installed via the bash script in ZSH. I deleted it and reinstalled it using the homebrew installation, and it's working now. 🤷‍♂

from fnm.

Schniz avatar Schniz commented on June 19, 2024

Maybe there was a weird error on a previous version of the installation script?
This has to be well tested. It isn’t. I’m sorry about that!

from fnm.

cem2ran avatar cem2ran commented on June 19, 2024

I've just run into the same issue running the script in bash on linux (debian).

from fnm.

Schniz avatar Schniz commented on June 19, 2024

Closing for inactivity

from fnm.

Schniz avatar Schniz commented on June 19, 2024

hmmm, which zsh are you running? what's your setup?

from fnm.

Vinlock avatar Vinlock commented on June 19, 2024

That code snippet seems out of date and I can't seem to see how to auto rehash after changing :(

from fnm.

Schniz avatar Schniz commented on June 19, 2024

@Vinlock What do you mean?
This is the whole point of fnm. What are you experiencing?

from fnm.

Schniz avatar Schniz commented on June 19, 2024

can you share echo $PATH with me? 😁

from fnm.

Schniz avatar Schniz commented on June 19, 2024

haha all good! happy that it works for you 😃
next time you can: source ~/.zshrc and call it a day. Or open a new tab, and close the older one 😃

from fnm.

Vinlock avatar Vinlock commented on June 19, 2024

haha all good! happy that it works for you 😃
next time you can: source ~/.zshrc and call it a day. Or open a new tab, and close the older one 😃

Yeah, I had done the source command and it didn't effect anything it seemed for some reason. Though restarting iTerm made it work. New tab may have done the trick too. Just wondering what else it needed aside from source ~/.zshrc 🤔

from fnm.

Schniz avatar Schniz commented on June 19, 2024

maybe you still had nvm installed on the current shell. I believe there is precedence for Bash functions over $PATH executables

from fnm.

redeemefy avatar redeemefy commented on June 19, 2024

I guess my issue belongs here instead
#370 (comment)

from fnm.

spiroid avatar spiroid commented on June 19, 2024

I never took the time to give some feedback here and I'm sorry for that.
I gave fnm another try recently and it perfectly works and I no longer have this issue!
Thanks a lot for your work 💯

from fnm.

orlandosh avatar orlandosh commented on June 19, 2024

I ran into the same problem. Every node version switch required rehash in my zsh shell. Turned out the problem was that no default node version was set in fnm. Once I ran fnm default x.x.x versions started switching correctly

The same happens to me. But I intentionally want to use system as default. If I set 20 as default, it switches to 14 when needed. If I set system as default, I need to use rehash every time, even if I manually enter fnm use 14.

To keep up with the latest node version, I prefer using system as dnf takes care of it, and then I only use fnm for project-specific requirements.

Does anyone have an idea why I need rehash when fnm default is set to system?

from fnm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.