GithubHelp home page GithubHelp logo

Comments (35)

FabioAntunes avatar FabioAntunes commented on July 1, 2024 2

@jiaweihli have you tried running nvm alias default 6.9.0 this will set your default node version to 6.9.0 (feel free to chose another one) whenever you open a new terminal?

@Lordnibbler why are you putting the .nvmrc on your home path ~/ ? that file should be inside your project folder. Let's imagine you are working on project that requires a very specific node version, let's say v4.4.4 you would do something like this:

cd /path/to/your/project
echo "4.4.4" > .nvmrc

Et voilΓ  now when you use node inside this folder, it will pick the .nvmrc and use that specific version.

from fish-nvm.

jorgebucaran avatar jorgebucaran commented on July 1, 2024 1

@jiaweihli Just a reminder that there is also:

I use verman personally.

from fish-nvm.

jklmli avatar jklmli commented on July 1, 2024 1

@FabioAntunes Yes, I've done that and it works correctly in bash - but not in fish.

from fish-nvm.

jklmli avatar jklmli commented on July 1, 2024 1

It does work correctly if I set nvm use default in ~/.config/fish/config.fish, but this adds an extra 1 second overhead to every new terminal.

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024 1

@jbucaran That's why I created this so whenever you use node, npm, nvm and now also yarn, it checks if there's a node already sourced, if not either source a local .nvmrc or source the default alias.

@jiaweihli I'm really sorry, but are you sure you have nvm properly installed? I have been using this since day one and I have never had any problems. I also have a couple of friends who use this and everything works for them. I know this sounds clichΓ©, but could you please uninstall nvm and install it again using fisherman

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024 1

Ok, I discovered your problem @tanc, you have node installed outside of nvm, that makes node global available. So since you already have node on your $PATH, fish-nvm doesn't source nvm. One solution is either uninstalled it and just use nvm, or wait a couple of days. I'm working on fix for this, so even if node exists we always source nvm

from fish-nvm.

richardpringle avatar richardpringle commented on July 1, 2024 1

@FabioAntunes, thanks for the response!

I just realized that I'm in the fisherman/nvm instead of creationix/nvm... woops!

It actually appears as though I needed to call nvm use (with no arguments) once in the folder with the .nvmrc file and it started working after that.

^^^
I guess this is for anyone who stumbles upon this issue from a google search even if you aren't using fisherman.

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024 1

@lukiano that's the default behaviour check https://github.com/creationix/nvm#deeper-shell-integration

If you want you can create some sort of script that listens for folder changes and checks if there's a .nvm

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

Thanks @jiaweihli, will have a look and let you know.

from fish-nvm.

Lordnibbler avatar Lordnibbler commented on July 1, 2024

same problem! fish 2.4

i cheated by:

echo 'default' > ~/.nvmrc
echo 'nvm use' > ~/.config/fish.config

but this is not ideal

from fish-nvm.

jorgebucaran avatar jorgebucaran commented on July 1, 2024

@FabioAntunes Correct me if I am wrong, but isn't this precisely how nvm works? The tradeoff is between this extra second on every terminal or the manual extra step to run nvm yourself before using node.

from fish-nvm.

jklmli avatar jklmli commented on July 1, 2024

Sorry for radio silence. I've tried installing fisherman nvm as well as nvm, no luck.
At this point I'm just eating the extra manual work 😞

Let me know if there's any logs I can send you that would help you debug this.

from fish-nvm.

jorgebucaran avatar jorgebucaran commented on July 1, 2024

@jiaweihli Installing fisherman again will not fix anything, since fisherman is just a single function that goes into your ~/.config/fish/functions directory. There's nothing special or antyhing that deviates from standard fish, so perhaps there is an issue with your fish? :)

Can you try using fnm / verman and let me know if the problem goes away?

from fish-nvm.

fanaugen avatar fanaugen commented on July 1, 2024

I have the exact same problem as @jiaweihli. fnm works fine, but I was kind of hoping to be able to continue using NVM, because I use it on bash also.

If I understand @jbucaran’s comment above correctly, the 1 second that it takes NVM to run seems inevitable anyway? I certainly experience a 1 second lag when starting up bash, where the NVM script is configured to run.

from fish-nvm.

jorgebucaran avatar jorgebucaran commented on July 1, 2024

@fanaugen I'm a bit confused. This is fisherman/nvm. I understand this plugin was created so one can keep using nvm, as usual, with fish.

Before this plugin, I made fnm, which does things differently, but also supports .nvmrc to ease with the migration. It's still supported and it has many users.

Then, I made verman which is a configuration-only, much simpler approach, and it's what I use nowadays.

@FabioAntunes Is nvm/node for you? Might want to upgrade your fish to 2.5 to see if anything breaks by the way.

EDIT:

I certainly experience a 1 second lag when starting up bash, where the NVM script is configured to run.

1 second lag, give or take is inevitable, but tapping into fish function autoloading, we can delay this lag to the moment we actually intend to use node, thus solving the slow shell start problem.

This is implemented by creating a fish wrapper function around the node/npm (now yarn too?) binaries.

This is how fnm and verman works and to some extend, fisherman/nvm, but you'll have to ask Fabio who is the author of fisherman/nvm for the details.

from fish-nvm.

fanaugen avatar fanaugen commented on July 1, 2024

Sorry for creating confusion. I was just trying to say that, as @jiaweihli pointed out, fisherman/nvm doesn’t "remember" the node version used across shell sessions. To reproduce:

  • type nvm alias default stable, then nvm use default, then node --version β†’ this will report the node version installed by NVM and aliased with stable
  • but as soon as you open a new fish session, node --version falls back to the "system" node executable, not the one installed by NVM. So you have to retype nvm use default in order to use the NVM-installed one (and the global npm modules installed with it).

Not sure whether this is intended behaviour, but the --no-use on this line suggests that it might be.

from fish-nvm.

balupton avatar balupton commented on July 1, 2024

this worked fine for me:

balupton@balbook ~> node -v
fish: Unknown command 'node'

balupton@balbook ~> fisher nvm
Installing 1 plugin/s
OK Fetch nvm github.com/fisherman/nvm
Done in 3s 691ms

balupton@balbook ~> node -v
Now using node v7.8.0 (npm v4.4.4)
v7.8.0

then in a new terminal:

balupton@balbook ~> node -v
Now using node v7.8.0 (npm v4.4.4)
v7.8.0

from fish-nvm.

tanc avatar tanc commented on July 1, 2024

I also have this problem where opening a new shell will not switch to the default node version. I've uninstalled and re-installed nvm and fisher nvm but its still not working.

Following the steps that @balupton mentioned above I also get a working node version, but not the version I have specified as my default when I used nvm alias default lts/argon

New terminal always shows:

$ node --version
v7.10.0

Then I have to do:

$ nvm use default
Now using node v4.8.3 (npm v2.15.11)

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

@tanc can you do me a favour? Run echo $PATH and paste the output please.

from fish-nvm.

tanc avatar tanc commented on July 1, 2024
$ echo $PATH
/Users/tanc/.rvm/gems/ruby-2.4.0/bin /Users/tanc/.rvm/gems/ruby-2.4.0@global/bin /Users/tanc/.rvm/rubies/ruby-2.4.0/bin /Users/tanc/.rvm/bin /bin /Users/tanc/.composer/vendor/bin /Users/tanc/.fzf/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

@tanc can you also run which node on a freshly opened terminal

@jiaweihli @Lordnibbler @fanaugen

Sorry for this late request, if you guys are still using this Package, could you guys run echo $PATH on a fresh fish terminal, but make sure you guys remove any cheating i.e. nvm use inside the fish.config

from fish-nvm.

tanc avatar tanc commented on July 1, 2024
$ which node
/usr/local/bin/node

from fish-nvm.

tanc avatar tanc commented on July 1, 2024

Fantastic, thanks @FabioAntunes

I'll wait a couple of days and test your fix :)

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

@tanc run fisher update nvm and give it a try

from fish-nvm.

tanc avatar tanc commented on July 1, 2024

Brilliant! Works great after update

from fish-nvm.

jklmli avatar jklmli commented on July 1, 2024

This removed the delay-on-new-terminal issue I was having as well, but I noticed an issue:

β‹Š> kevin at origin in ~ since Tue May 30 12:20:41
$ nvm current
system
β‹Š> kevin at origin in ~ since Tue May 30 12:20:43
$ cat ~/Desktop/test.js
#! /usr/bin/env node

console.log('hello world')
β‹Š> kevin at origin in ~ since Tue May 30 12:20:46
$ ~/Desktop/test.js
hello world
β‹Š> kevin at origin in ~ since Tue May 30 12:20:48
$ nvm current
system
β‹Š> kevin at origin in ~ since Tue May 30 12:20:51
$ node --version
Now using node v6.10.2 (npm v3.10.10)
v6.10.2
β‹Š> kevin at origin in ~ since Tue May 30 12:20:55
$ nvm current
v6.10.2
β‹Š> kevin at origin in ~ since Tue May 30 12:20:58
$ ~/Desktop/test.js
hello world
β‹Š> kevin at origin in ~ since Tue May 30 12:21:01
$ nvm current
v6.10.2

It looks like the node switching logic has been moved to the first instance of running node on the command line. I notice the same delay when I run node --version for the first time, but not the second time.

If you're running a shell/python script that calls out to node, it might not be using the default version (if you just opened a new shell).

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

Yep that's the point, to only source node when we need.

You can either keep doing what you were doing, source nvm on shell init. Or you can create a command called node on some directory of yours.

$ mkdir ~/mycommands/
$ cd ~/mycommands/
$ touch node
$ chmod +x node

Edit the file and paste this:

#! /usr/bin/env fish

__nvm_run "node" $argv

Add this line to your config.fish set -g -x PATH ~/mycommands $PATH

You can do it manually or by just running this

$ echo "set -g -x PATH ~/mycommands $PATH"  >> ~/.config/fish/config.fish

from fish-nvm.

saneef avatar saneef commented on July 1, 2024

Also, in the freshly loaded shell. The globally installed packages for default will be missing; unless run node or nvm use default once.

from fish-nvm.

richardpringle avatar richardpringle commented on July 1, 2024

Hey guys,

I'm on nvm 0.33.2 and I installed nvm through the zsh plugin. Default works fine, nvm use works fine, but the .nvmrc file does not work.

I have a bunch of node versions all over the place so that might be my problem but when I call node, it's definitely using the version supplied by nvm.

any ideas?

from fish-nvm.

FabioAntunes avatar FabioAntunes commented on July 1, 2024

@richardpringle check if in any of these files ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc

nvm is being autoloaded, this is the bit that does that:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

if so you need to remove that.

from fish-nvm.

weedgrease avatar weedgrease commented on July 1, 2024

I'm having this issue and I'm a bit confused. I've removed any instance of nvm sourcing from the files mentioned above and it doesn't seem to change anything.

I currently can't even call which when I first open my shell. Calling node --version prints out 6.9.2 which is what I would expect, but calling which only works if I have nvm use default in my config.fish.

kevin ~ > which
env: node: No such file or directory
kevin ~ > which node
env: node: No such file or directory
kevin ~ > nvm use default
Now using node v6.9.2 (npm v3.10.9)
kevin ~ > which node
/Users/kevin/.nvm/versions/node/v6.9.2/bin/node
kevin ~ > which
usage: which [-as] program ...

from fish-nvm.

richardpringle avatar richardpringle commented on July 1, 2024

I actually soft linked to the same node version as my default alias in /usr/local/bin so I can still use node from other terminals. I believe the reason that which node isn't working for you is because the node command doesn't actually call an executable directly, it calls a shell function that uses nvm path variables to figure out which executable can be called.

I'm sure one of the other commenters in this issue will correct me if I'm wrong.

from fish-nvm.

lukiano avatar lukiano commented on July 1, 2024

Is there any update on this issue? On a new shell, if I go to a folder with .nvmrc, calling node loads the correct version (as specified in that file), but if then I go to another folder with .nvmrc pointing to a different version, executing node does not switch to that version, I have to execute nvm use first.

from fish-nvm.

lukiano avatar lukiano commented on July 1, 2024

Ok thanks, I didn't know that was the right behaviour. I'd certainly have a script that listens for folder changes, but also performs the lazy loading. It looks like the core of the magic is in __nvm_run.fish ? Anyway I'll take a deeper look.

from fish-nvm.

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.