Comments (35)
@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.
@jiaweihli Just a reminder that there is also:
I use verman personally.
from fish-nvm.
@FabioAntunes Yes, I've done that and it works correctly in bash - but not in fish.
from fish-nvm.
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.
@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.
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.
@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.
@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.
Thanks @jiaweihli, will have a look and let you know.
from fish-nvm.
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.
@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.
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.
@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.
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.
@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.
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
, thennvm use default
, thennode --version
β this will report the node version installed by NVM and aliased withstable
- 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 retypenvm 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.
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.
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.
from fish-nvm.
@tanc can you do me a favour? Run echo $PATH
and paste the output please.
from fish-nvm.
$ 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.
@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.
$ which node
/usr/local/bin/node
from fish-nvm.
Fantastic, thanks @FabioAntunes
I'll wait a couple of days and test your fix :)
from fish-nvm.
@tanc run fisher update nvm
and give it a try
from fish-nvm.
Brilliant! Works great after update
from fish-nvm.
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.
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.
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.
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.
@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.
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.
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.
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.
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)
- Can't launch node REPL anymore HOT 8
- Error: Cannot find module 'prompt' HOT 2
- Fish nvm: 'node' is currently not installed, try running npm i -g node HOT 7
- Breaks `which`? HOT 11
- Autocomplete is very slow HOT 3
- Update Docs HOT 2
- Breaks reverse search plugin
- Quesiton about lazy loading and the`init_nvm` event HOT 2
- nvm.sh must be linked/copied to $HOME/.nvm HOT 1
- Usage with "fundle"
- Node prints all output first when quitting the program HOT 2
- Error when using any nvm's node HOT 3
- Autocomplete very slow. HOT 1
- type: Invalid combination of options HOT 8
- How to uninstall? HOT 1
- Fish 3.2.2 update issue HOT 3
- Auto nvm use when detecting .nvmrc ? HOT 3
- .nvmrc should be searched by traversing the directory tree up HOT 1
- alias command is not defined HOT 1
- does not fix "NVM not found" error when creating a new tmux pane HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fish-nvm.