jorgebucaran / nvm.fish Goto Github PK
View Code? Open in Web Editor NEWThe Node.js version manager you'll adore, crafted just for Fish
Home Page: https://git.io/nvm.fish
License: MIT License
The Node.js version manager you'll adore, crafted just for Fish
Home Page: https://git.io/nvm.fish
License: MIT License
Projects suchs as direnv can use node, but it depends on that this is set:
set -gx NODE_VERSIONS ~/.config/nvm
set -gx NODE_VERSION_PREFIX ''
Is there any chance these could be set automatically in conf.d/nvm.fish or is it a bad idea?
I installed the latest NPM package with yarn
as:
yarn global add [email protected]
But still show another version
❯ npm --version
5.3.0
❯ whereis npm
npm: /usr/bin/npm /data/settings/.config/fnm/bin/npm /home/ed8/.yarn/bin/npm
❯ /usr/bin/npm --version
3.10.10
❯ /data/settings/.config/fnm/bin/npm --version
5.3.0
/data/projects/employee-app-front front-login-form-errors
❯ /home/ed8/.yarn/bin/npm --version
5.4.2
How do I use the one from yarn?
nvm use lts
installs version 12.11.1 (as of oct, 7) while the latest lts version is 10.16.3 according to https://nodejs.org/en/download/
$ fisher fnm
$ fnm 6.11.3
fnm: I couldn't find '6.11.3' in the version index.
It seems to work after you run fnm ls
. I'm guessing it has to first download the version index before being able to query it.
fnm <version>
should probably automatically download the version index if it doesn't exist.
I've just switched from zsh to fish, and installed fnm with fisherman.
It seems to be installed correctly but I'm getting an error with the completions, after typing any character after the fnm command it returns an inline error:
Also, when I try to access to a folder with a .nvmrc
file it apparently changes the version (at least if the version is not in the system it start the download) but after that node is not responding:
Any idea? Is there a way to debug the error?
In switching over from (non-fish) nvm, I was tripped up by the "use the .nvmrc-specified version" command being nvm
rather than nvm use
. Would you be open to supporting argument-less nvm use
to not diverge from nvm? What about having argument-less nvm
output usage notes, like in nvm?
Steps to repro:
> fnm 8.12.0
> npm i eslint -D // eslint is just an example. Happens with any package. Or even doing npm i twice throws the same error
You get pna.nextTick is not a function
error. The same thing works fine with v8.11.4. I've tried cleaning node_modules and stuff but the error remains.
Hi, I seem to be getting this issue when I run nvm
any help please? It downloaded the node version then I get this error.
Opening an issue here, which I also reported @ the fisherman/nvm repo: FabioAntunes/fish-nvm#4
npm <Tab>
auto-complete print out the content of npm completion
instead of showing correct completions.
This behavior doesn't happen fisherman/verman or omf/nvm
I think an nvm current
command would be useful for symmetry with the original nvm and most other fish nvm addons. This would make it simpler for a bash/zsh user to switch to fish and be greeted with the same commands.
Weirdness, fnm <version>
always installs .config/fnm/lib/node_modules/npm/bin/npm-cli.js v5.6.0
which npm
/home/elijah/.config/fnm/bin/npm
npm --version
5.6.0
ls -l /home/elijah/.config/fnm/bin/npm
/home/elijah/.config/fnm/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js*
rm -f ../lib/node_modules/npm/bin/npm-cli.js
npm --version
The program 'npm' is currently not installed. You can install it by typing:
sudo apt-get install npm
~/.config/fish/functions/__fnm_run_bin_as.fish (line 52):
command npm $argv
^
in function “__fnm_run_bin_as”
called on line 2 of file ~/.config/fish/functions/npm.fish
with parameter list “npm --version”
in function “npm”
called on standard input
with parameter list “--version”
fnm 8.11.3
npm --version
5.6.0
Thank you author for making such good tool.
Are there any commands to remove downloaded version like nvm rm 11.6.0
by any chance?
Hi guys, nvm
has several aliases for lts
versions that are not supported in fnm
. For example: lts/carbon
and presumably lts/*
don't work and output the following error when a .nvmrc
file is present:
fnm: It seems 'lts/carbon' is not a valid version number.
Hint: Examples of valid node versions:
v5.10.1
latest
0.12
lts
I think that if you want to support .nvmrc
those aliases should also work with fnm
.
Hi @jorgebucaran do you have thoughts on https://github.com/Schniz/fnm ?
Would you recommend using fish-nvm
instead?
Thanks!
The nvm.sh version sets the current node based on nvmrc when doing nvm use
but this version fails with
nvm: invalid version number or alias: ""
Adding a path in the home directory to the universal var fish_user_paths is not ideal. For example, for my install of fish-nvm it becomes SETUVAR fish_user_paths:/home/myusername/\x2econfig/nvm/13\x2e0\x2e0/bin
This is problematic due to the reason that some of us version control our home directory and certain parts of it, such as ~/.config/fish/ in order to have a unified working experience over multiple hosts.
Unfortunately there is no way to alter fish_variables
so that it contains e.g. ~ (so it becomes agnostic as to what ny username is). This is due to that fish expands the path before adding it to fish_variables
to the full path.
There are other reasons why setting an explicit user name is not ideal, such as in the case if a user changes his username. This would also invalidated the universal var set by fish-nvm. In short, no paths should be added to universal vars if they are a path in the user directory.
As such, it would be better to add the path to conf.d/nvm.fish as in there one can do set -gx PATH ~/some/path
and it will be agnostic to the user name. It would also let me use different nodejs versions in different shells opened in fish.
fnm
could try to select a version with the engines
rule in package.json
if it exists. nvm
has some precedent for this in this discussion and this PR.
I've never written any fish
but I could give a PR for this a shot if maintainers are open to it being merged.
fish-nvm reads .nvmrc
on call to nvm
without parameters, but, the original NVM uses nvm use
command for this.
It would be good to support this for muscle-memory compatibility
Current behaviour:
> nvm use
nvm: invalid version number or alias: ""
I just installed this package to hopefully have an improved nvm experience with Fish shell...
Here's what I discovered:
Native nvm compat issues:
nvm current
doesn't exist, in native nvm the current
flag will list the current active Node.js version in use.nvm ls-remote
doesn't exist, in native nvm the ls-remote
flag will list the available Node.js versions that can be installednvm install x.y.z
doesn't exist, in native nvm the install
flag will install the x.y.z specified or aliased version of Node.js.fish-nvm issues:
nvm ls
lists the remote Node.js versions that can be installed, though it incorrectly lists the Node.js v12.x releases as "LTS", The Node.js v10.x releases are the current "LTS" releases, Node.js v12.x doesn't enter "LTS" until later this yearnvm use lts
installs the latest v12.x release, I expected it to install the latest v10.x releasenpm issues:
npm
is not straight forward, a fish helper function for npm would be useful, I had to dig around looking for the included version of npm in the Node.js release installed, I expected it to use ~/.nvm
though fish-nvm actually installs Node.js into ~/.config/nvm/x.y.z
~/.config/nvm/x.y.z
is troublesome for keeping global packages installed between npm versions.Anyhow, thanks for the fish-nvm package, after discovering the above issues I now understand how this fish-nvm package is expected to work so I'll play around some more and try to use the fish-nvm installed comments rather than the native nvm commands I'm used to, I think for the most part I should be able to work around most issues.
With the above workarounds, it would still be great to get some of these other aliases added to fish-nvm, primarily so that if instructed to run certain nvm commands from another repo those nvm commands would also be available in fish-nvm.
node -v
9.0.0
cd foo
'1.0.0' > .fnrmc
refresh
node -v
1.0.0
cd ..
node -v
1.0.0 ❗️
I feel like .fnmrc
should only temporarily swap node version. :\
Is there a way to list node versions? In normal nvm nvm ls
typically lists the installed node versions and you are able to find and delete ones you no longer want. Is there an equivalent here?
When I type node
and press Tab, I'm getting the following error:
node __fish_not_contains_opt: Unknown option --version
__fish_not_contains_opt: Unknown option --version
__fish_not_contains_opt: Unknown option --version
__fish_not_contains_opt: Unknown option --eval
I often use nvm's ability to filter the output of nvm ls-remote
to versions that start with the supplied optional argument. For example nvm ls-remote 10.2
shows 10.2.0 and 10.2.1.
Would it be useful to add similar functionality to fnm?
I've put 8.6.0 in ~/.node-version
, and
# auto switch node versions based on .node-version file
function node -d "Server-side JavaScript runtime"
verman "node"
command node $argv
end
in my ~/.config/fish/functions/node.fish
file, so that node versions are automatically picked up. Navigating to ~
does indeed select 8.6.0 but if I travel to any other folder below, then node falls back to the installed version, which for me is currently 8.5.0. Is this as intended? Or have I set up my config incorrectly?
related: npm/npm#19032, npm/npm#19166
Every time I switch to 4.2.6
and back to 8.x.x
I broke my NPM:
$ fnm use 4.2.6
$ fnm use 8.9.3
$ npm install
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/util/types'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ed8/.npm/_logs/2017-12-12T15_02_45_814Z-debug.log
Hey 👋,
Sorry for polluting your issues section. I really like the demo video! Did you use any specific software to capture it?
Thanks a lot 🎉
If nvm.fish tries to set -U fish_user_paths ... $fish_user_paths
, the following error can occur if $fish_user_paths
has global scope:
set: Universal variable 'fish_user_paths' is shadowed by the global variable of the same name.
See: #107
no matter what version i ask for, nvm
ignores it and installs 14.7
. i installed it with Fundle. am i doing something wrong?
~ ⟩ nvm use 10
fetching https://nodejs.org/dist/v14.7.0/node-v14.7.0-darwin-x64
######### 7.9%^C⏎
~ ⟩ nvm use 10.22.0
fetching https://nodejs.org/dist/v14.7.0/node-v14.7.0-darwin-x64
######### 7.9%^C⏎
~ ⟩ nvm use dubnium
fetching https://nodejs.org/dist/v14.7.0/node-v14.7.0-darwin-x64
######### 7.7%^C⏎
~ ⟩ echo 10.22.0 > .nvmrc
~ ⟩ nvm
fetching https://nodejs.org/dist/v14.7.0/node-v14.7.0-darwin-x64
######### 7.7%^C
Looks like you're checking for the OS here:
Also, this code isn't putting out an error for me:
howdoicomputer@spacebison ~/w/findahome> fnm 6.9.5
howdoicomputer@spacebison ~/w/findahome> echo $status
0
howdoicomputer@spacebison ~/w/findahome> which node
howdoicomputer@spacebison ~/w/findahome> node -v
fish: Unknown command 'node'
I may look into drafting a pull request for you!
An insteresting ability could be something like:
fnm carbon
To change to the latest Carbon version
1. How can i view the versions that i already installed without looking in ~/.config/nvm
?
fnm
showed these by running it without any argument if i remember correctly (unlike fnm/nvm ls
which lists all available versions)
2. How can i remove an installed version of node?
Unlike fnm
, the new nvm
does not have a rm
option anymore :(
Would love to see support for installations on Windows via MSYS2
Current behavior:
$ nvm use lts
nvm: OS not implemented -- request it on https://git.io/fish-nvm
$ uname -smo
MSYS_NT-10.0-18362 x86_64 Msys
To show case what I mean, I am going to paste the information another tool called direnv does in a recent release:
Migrating the allow data to the new location
The allowed .envrc permissions used to be stored in the XDG_CONFIG_HOME. It's
better to keep that folder for user-editable configuration so the data is
being moved to XDG_DATA_HOME.moving /home/userA/.config/direnv/allow to /home/userA/.local/share/direnv/allow
creating a symlink back from /home/userA/.local/share/direnv/allow to /home/userA/.config/direnv/allow for back-compat.All done, have a nice day!
As such, it would make sense for nvm to also migrate from XDG_CONFIG_HOME
to XDG_DATA_HOME
. The config is used for user-editable config whereas the data dir should be used for data written by the program such as nvm.
One of many reasons to do this is that a lot of users utilize dotfile support to backup configuration data, and that is often done for the XDG_CONFIG_HOME
dir. Since nvm downloads binaries, it would mean many users might commit binaries to their git repo if they do not take care. Users do not expect the config dir to contain binaries.
I've just started from scratch again, removed fnm and reinstalled again, and still no luck with the version switching.
I'm using .nvmrc
files, but also tried with .fnmrc
and no luck.
How can I help to debug it? I'm new to fish and I would like to start contributing.
Here's the flow I tried and no luck:
As of today (Jul 19, 2019), nvm use lts
picks up 12.6.0 which is indeed a Current release, but not an Active LTS yet. I believe it should pick up 10.16.0 as what nvm use dubnium
currently does, until v12 becomes LTS in October.
If there is a mechanism to turn fnm off, it doesn't seem to be documented.
It would nice if .fnmrc file in parent directory would be applied to all child directories. This can be implemented by traversing the directory tree up while searching the .fnmrc file.
Example:
mkdir -p parent/children
cd parent
echo "6.9.3" > .fnmrc
node -v # Should be 6.9.3
cd children
node -v # Should also be 6.9.3
I've neglected this project for a long time. Now, I'd like to rewrite it (from scratch), fix all the issues that have collected over the years and rename it (fnm has poor discoverability/SEO). 100% backward compatibility is not a goal.
I'll be updating this issue to clarify exactly what will change, what features will be added or deprecated, what breaking changes will be introduced, and everything else that you need to know about.
I don't understand how to get npm. I thought npm installed alongside node if I do nvm use 10.21.0
, but the command (npm) isn't recognized regardless of whatever version of node I get. If I try to install npm using apt, it installs an old version of node along with it instead of the version I need. Is there any way to fix this?
Hello,
I'm doing nvm use lts
and it's working great. 😄
But how can I update node LTS
using NVM when a new version is released?
Cheers
When interacting with node
I see this error. Things seem to work alright though.
Thanks for fisher and this great little add-on. I recently switched to it, and I love how simple and quick it is.
One thing I ran into recently, is that when I'm in a dir that has a .nvmrc file and I do nvm
to switch to the .nvmrc node version, the .nvmrc gets overwritten with the same value but with a newline added if there wasn't one already. While that doesn't cause a problem per se, it does create a small annoyance in a GitHub repo with a .nvmrc that doesn't already have a newline.
My expectation was that this particular mode would be a read-only operation on .nvmrc, so I was surprised to see unstaged changes in a repo, e.g.:
❯ git status -sb
## master...origin/master
~/dev/jobdetails master
❯ cat .nvmrc
lts/*
~/dev/jobdetails master
❯ node --version
v8.17.0
~/dev/jobdetails master
❯ nvm
~/dev/jobdetails master*
❯ node --version
v12.14.0
~/dev/jobdetails master*
❯ git diff
diff --git a/.nvmrc b/.nvmrc
index 1a2f5bd..b009dfb 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-lts/*
\ No newline at end of file
+lts/*
It's probably good for .nvmrc to have a newline, but it's not a requirement, and I don't always have control over all the repos I interact with that have a .nvmrc.
Would you be open to not overwriting .nvmrc in the case where nvm
reads the .nvmrc version?
After fighting with nvm for an hour, stumbled upon your nice plugin. Worked perfectly. Works better than other solutions. Million kudos for the quality work. 👌
👋
What's the problem?
node
. Global modification of PATH
breaks them.fish_user_paths
affects all terminal sessions, therefore, all projects.node
that will automatically call the appropriate node
version based on the context (without the need to call nvm
explicitly, mainly for the scripts) and would love to use this package as a dependency.Proposed solution
fish_user_paths
, instead modify global PATH
variable on the command usage that will affect only the current fish session.Are you willing to review and accept a PR for this?
Related: #93
cd
into dirs with an .nvmrc
/.fnmrc
set to a version of node that's not installed throw the error below. Once that version is installed (no notification of such, just waited a minute) it's fine to swtich directories again.
fish: Unknown command 'last_job_id'
~/.config/fish/functions/__fnm_version_download.fish (line 1):
last_job_id -l
^
in command substitution
called on line 62 of file ~/.config/fish/functions/__fnm_version_download.fish
in function '__fnm_version_download'
called on line 49 of file ~/.config/fish/functions/__fnm_use.fish
with parameter list '8.15.0 /Users/jwhitmarsh/.cache/fnm/versions/8.15.0'
in function '__fnm_use'
called on line 100 of file ~/.config/fish/functions/fnm.fish
with parameter list '8'
in function 'fnm'
called on line 35 of file ~/.config/fish/functions/__fnm_run_bin_as.fish
with parameter list '8'
in function '__fnm_run_bin_as'
called on line 3 of file ~/.config/fish/functions/node.fish
with parameter list 'node -v'
in function 'node'
called on line 8 of file ~/.config/fish/functions/__sf_section_node.fish
with parameter list '-v'
in command substitution
called on line 49 of file ~/.config/fish/functions/__sf_section_node.fish
in function '__sf_section_node'
called on line 1 of file -
from sourcing file -
called on line 61 of file /usr/local/Cellar/fish/3.0.0/share/fish/functions/eval.fish
in function 'eval'
called on line 31 of file ~/.config/fish/functions/fish_prompt.fish
in function 'fish_prompt'
called on standard input
in command substitution
called on standard input
fish: Unknown command 'await'
~/.config/fish/functions/__fnm_version_download.fish (line 61):
await (last_job_id -l)
^
in function '__fnm_version_download'
called on line 49 of file ~/.config/fish/functions/__fnm_use.fish
with parameter list '8.15.0 /Users/jwhitmarsh/.cache/fnm/versions/8.15.0'
in function '__fnm_use'
called on line 100 of file ~/.config/fish/functions/fnm.fish
with parameter list '8'
in function 'fnm'
called on line 35 of file ~/.config/fish/functions/__fnm_run_bin_as.fish
with parameter list '8'
in function '__fnm_run_bin_as'
called on line 3 of file ~/.config/fish/functions/node.fish
with parameter list 'node -v'
in function 'node'
called on line 8 of file ~/.config/fish/functions/__sf_section_node.fish
with parameter list '-v'
in command substitution
called on line 49 of file ~/.config/fish/functions/__sf_section_node.fish
in function '__sf_section_node'
called on line 1 of file -
from sourcing file -
called on line 61 of file /usr/local/Cellar/fish/3.0.0/share/fish/functions/eval.fish
in function 'eval'
called on line 31 of file ~/.config/fish/functions/fish_prompt.fish
in function 'fish_prompt'
called on standard input
in command substitution
called on standard input
nvm use
always returns the error: "nvm: invalid version number or alias: ..." regardless of which version I try to enable. This is true whether the version is read from an .nvmrc
file or passed directly as an arg to the command.
$ nvm use lts
nvm: invalid version number or alias: "lts"
$ nvm use latest
nvm: invalid version number or alias: "latest"
$ echo 10.0 >.nvmrc
$ nvm
nvm: invalid version number or alias: "10.0"
This has been working flawlessly for the past however long I've been using it (a few months?), but then all of the sudden this. I haven't made any modifications to my setup other than having recently run:
$ fisher self-update && fisher
My current fish version is: fish, version 3.0.2
.
Let me know if I can provide any other information. Thank you!
Thanks for this great tool, love the fish native way instead of mess with nvm/bass
.
when switching version using fnm use x.x.x
, this line (cp -fR "$fnm_cache/versions/$v/bin/." "$fnm_config/bin"
) failed with the below error:
cp: symlink: ../lib/node_modules/npm/bin/npx-cli.js: File exists
cp: symlink: ../lib/node_modules/npm/bin/npm-cli.js: File exists
fish, version 2.7.1
fisherman version 2.12.0
Environment: MacOS High Sierra 10.13.6
, MBP 2016 15".
This result in only node
version gets updated because the node
executable is copied over, however the lib
is not copied so npm
version is out of sync with node
, which is not ideal.
Something like this already exists for oh my fish.
If you could integrate this functionality in fnm, that would be super nice.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.