fabioantunes / fish-nvm Goto Github PK
View Code? Open in Web Editor NEWnvm wrapper for fish-shell
License: MIT License
nvm wrapper for fish-shell
License: MIT License
The brew formula leaves nvm.sh
at $(brew --prefix nvm)/nvm.sh
without linking it to~/.nvm/nvm.sh
. Consequently, the following code fails to source the file properly.
set -q NVM_DIR; or set -gx NVM_DIR ~/.nvm
set -q nvm_prefix; or set -gx nvm_prefix $NVM_DIR
bass source $nvm_prefix/nvm.sh --no-use ';' nvm $argv
internal/modules/cjs/loader.js:651
throw err;
^
Error: Cannot find module 'prompt'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
at Function.Module._load (internal/modules/cjs/loader.js:575:25)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object. (/usr/local/lib/node_modules/react-native-cli/index.js:43:14)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
Can you help me ?
[Instruction: how to install this package with fundle]
Run:
fundle plugin 'FabioAntunes/fish-nvm'
fundle install
Add these lines to ~/.config/fish/config.fish
fundle plugin 'FabioAntunes/fish-nvm'
fundle init
Support yarn
and allow users to create their own functions for other global packages.
fish-nvm should include parent directories when searching .nvmrc.
For example:
$ echo 14 > .nvmrc
$ cd child
$ node -v
# still 16
Somewhere related: jorgebucaran/nvm.fish#45
Hi,
Autocompletion works on Fish 3 but is very slow.
Checkout this asciinema showing the issue
Thank you
Hi, I'm stuck with the following error message that came up out of nowhere. I didn't even change anything that I remember but I can't launch a node
REPL anymore:
~> node
internal/modules/cjs/loader.js:651
throw err;
^Error: Cannot find module '/Users/mmg'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
at Function.Module._load (internal/modules/cjs/loader.js:575:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
at internal/main/run_main_module.js:21:11
What works is env node
and also launching a bash and then node
.
I just reinstalled fisher, nvm, and fish-nvm but that didn't help.
Any ideas?
I am a new fish user and first off thanks for the plugin!
I've been trying to find a way to lazy load on a new shell, but I can't seem to find where the event init_nvm
is emitted in the function in init.sh
.
I think I found a work-around where I can lazy load nvm in fish. What do you think?
init.fish
to load_nvm
(this seemed to prevent it from running on new shell startup)emit load_nvm
to functions/nvm.sh
nvm $arg
it will load it on demandfunction init -a path --on-event load_nvm
if type -q fenv
set -q NVM_DIR; or set -gx NVM_DIR ~/.nvm
set -g nvm_prefix $NVM_DIR
type -q brew;
and test -e (brew --prefix)/Cellar/nvm;
and set -g nvm_prefix (brew --prefix nvm)
fenv source $nvm_prefix/nvm.sh >/dev/null ^&1
end
end
function nvm -d "Node version manager"
emit load_nvm
if test -e $nvm_prefix/nvm.sh
if not type -q fenv
echo "You need to install foreign-env plugin"
return 1
end
fenv source $nvm_prefix/nvm.sh --no-use ';' nvm $argv
else
echo "You need to install nvm itself (see https://github.com/creationix/nvm#installation)"
return 1
end
end
Hello -- Thank you for the plugin.
I'm using a Mac M1 with alacritty and tmux.
It seems to work fine when I open a new terminal. It also seems to work fine when I start a new tmux session. However, when I create a new pane or window within tmux, I get the "NVM not found" error after it complains:
env: node: No such file or directory
Is this something you have encountered? Is something I can do to point tmux to the right place?
I believe that loading nvm.sh after intialization would be better,
otherwise It won't inject or modify necessary ENV VARIABLES into global, like $PATH
, where stores some global dependencies installed by NPM. Only I can access the bin after type node
or nvm
, it's annoying, right?
I have fisher, nvm, and bass installed. NVM works just fine, except when I just run it with no arguments:
~ $ nvm
Node Version Manager
Note: <version> refers to any version-like string nvm understands. This includes:
- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
- default (built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with `nvm alias foo`
Any options that produce colorized output should respect the `--no-colors` option.
Usage:
nvm --help Show this message
nvm --version Print out the installed version of nvm
...
test: Missing argument at index 2
test: Missing argument at index 2
with exit code 0. Note the error messages at the end. Maybe there's an array indexing error? I've already tried reinstalling fisher, bass, and fisherman/nvm.
It's not a big deal; it works just fine otherwise. Thanks!
Currently there's a section suggesting fnm
:
Check out also fnm a pure fish node version manager with automatic version switching.
But in reality fnm
doesn't support that anymore, so it should be removed
jorgebucaran/nvm.fish#58 (comment)
I get following error whenever I run npm/node --version
after nvm use v8/12/3
. I don't get this error when I do nvm use system
/nvm unload
.
test: Expected a combining operator like '-a' at index 3
Standard input (line 21):
if type -fqP $argv[1]; and test "$stack[1]" != (which $argv[1])
^
in function 'run_command' with arguments 'npm --version'
called on line 68 of file ~/.local/share/omf/pkg/fish-nvm/functions/__nvm_run.fish
in function '__nvm_run' with arguments 'npm --version'
called on line 2 of file ~/.local/share/omf/pkg/fish-nvm/functions/npm.fish
in function 'npm' with arguments '--version'
(Type 'help test' for related documentation)
Fish nvm: 'npm' is currently not installed, try running npm i -g npm
What could be the cause? I have both latest fish
and fish-nvm
.
bower installed to global, fish known bower. When I restart fish that didn't know bower.
Hello, thank's for your plugin, really appreciate it. I was wondering if an easy way exist to automaticly call nvm use
when I'm in my project folder with an .nvmrc
file describing the current version of node needed for this project ?
Thank's :)
@FabioAntunes ๐
I'm trying to improve the Awesome Fish list and noticed both this package and @brigand's fast-nvm-fish are nvm wrappers (require nvm to be previously installed) and I was wondering how does one compare to the other. I plan to include both in the list, but I don't want to repeat myself.
This is what I have.
But it begs the question: isn't fish-nvm efficient or fast-fish-nvm completion-rich too?
Originally opened as a fish-shell issue: fish-shell/fish-shell#3152
After installing the nvm
plugin, I get garbage printed out when trying to get auto-completions for npm.
Removing nvm
plugin makes everything work fine.
Operating system: OS X El Capitan 10.11.5 (15F34)
Fish version: 2.3.0
Fish installed: using the official DMG.
Fish location: /usr/local/bin/fish
Terminal: iTerm2
Output:
$ npm <Tab>
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\>/dev/null\)\)\ \|\|\ return\ \$\?
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ COMP_LINE=\"\$COMP_LINE\"\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ COMP_POINT=\"\$COMP_POINT\"\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ npm\ completion\ --\ \"\$\{words\[@\]\}\"\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\>/dev/null\)\)\ \|\|\ return\ \$\?
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ COMP_LINE=\"\$line\"\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ COMP_POINT=\"\$point\"\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ npm\ completion\ --\ \"\$\{words\[@\]\}\"\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\>/dev/null\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ COMP_LINE=\$BUFFER\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ COMP_POINT=0\ \\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ npm\ completion\ --\ \"\$\{words\[@\]\}\"\ \\
\ \ \ \ \ \ _get_comp_words_by_ref\ -n\ =\ -n\ @\ -w\ words\ -i\ cword
\ \ \ \ \ \ cword=\"\$COMP_CWORD\"
\ \ \ \ \ \ words=\(\"\$\{COMP_WORDS\[@\]\}\"\)
\ \ \ \ compadd\ --\ \$\(COMP_CWORD=\$\(\(CURRENT-1\)\)\ \\
\ \ \ \ else
\ \ \ \ fi
\ \ \ \ if\ type\ _get_comp_words_by_ref\ \&\>/dev/null\;\ then
\ \ \ \ IFS=\"\$si\"
\ \ \ \ IFS=\$\'\\n\'\ COMPREPLY=\(\$\(COMP_CWORD=\"\$cword\"\ \\
\ \ \ \ IFS=\$\'\\n\'\ reply=\(\$\(COMP_CWORD=\"\$cword\"\ \\
\ \ \ \ IFS=\$si
\ \ \ \ let\ cword-=1
\ \ \ \ local\ cword\ line\ point\ words\ si
\ \ \ \ local\ si=\"\$IFS\"
\ \ \ \ local\ si=\$IFS
\ \ \ \ local\ words\ cword
\ \ \ \ read\ -Ac\ words
\ \ \ \ read\ -cn\ cword
\ \ \ \ read\ -l\ line
\ \ \ \ read\ -ln\ point
\ \ \ \ si=\"\$IFS\"
\ \ _npm_completion\ \(\)\ \{
\ \ _npm_completion\(\)\ \{
\ \ compctl\ -K\ _npm_completion\ npm
\ \ compdef\ _npm_completion\ npm
\ \ complete\ -o\ default\ -F\ _npm_completion\ npm
\ \ \}
\#
\#\ Installation:\ npm\ completion\ \>\>\ \~/.bashrc\ \ \(or\ \~/.zshrc\)
\#\ npm\ command\ completion\ script
\#\ Or,\ maybe:\ npm\ completion\ \>\ /usr/local/etc/bash_completion.d/npm
\#\#\#-begin-npm-completion-\#\#\#
\#\#\#-end-npm-completion-\#\#\#
add-user (Add a registry user account)
adduser (Add a registry user account)
bin (Display npm bin folder)
bugs (Bugs for a package in a web browser maybe)
c (Manage the npm configuration files)
cache (Manipulates package's cache)
config (Manage the npm configuration files)
ddp (Reduce duplication)
dedupe (Reduce duplication)
deprecate (Deprecate a version of a package)
docs (Docs for a package in a web browser maybe)
edit (Edit an installed package)
elif\ type\ compctl\ \&\>/dev/null\;\ then
elif\ type\ compdef\ \&\>/dev/null\;\ then
explore (Browse an installed package)
faq (Frequently Asked Questions)
fi
find (Search for packages)
find-dupes (Reduce duplication)
get (Echo the config value to stdout)
help-search (Search npm help documentation)
home (Docs for a package in a web browser maybe)
i (install a package)
if\ type\ complete\ \&\>/dev/null\;\ then
info (View registry info)
install (install a package)
isntall (install a package)
issues (Bugs for a package in a web browser maybe)
la (List installed packages)
link (Symlink a package folder)
rows 1 to 75 of 118
Hello,
First of all thank you for this package. It has been useful to me.
Since fish 3.0, I am encountering an issue where fish is sourced indefinitely.
This happen when I run commands that are added to /usr/local/bin/
by nvm_alias_command
.
It seems like the problem is related to __nvm_run
. Also, when I comment the __nvm_run
command in /usr/local/bin/node
for instance, a new fish shell is launched but doesn't cause recursion
I have installed fish-nvm using Oh my fish.
Thanks,
Amadou
Getting Fish nvm: 'node' is currently not installed, try running npm i -g node
everytime I try to run node
in a new sub-shell.
Nothing critical changed on my part, I think it's a recent change on this plugin:
% nvm --version
0.34.0
% fish --version
fish, version 3.0.2
% fisher --version
fisher version 3.2.8 ~/.config/fish/functions/fisher.fish
In version 3.2.0 of fish type -fqP
fails with the error type: Invalid combination of options
fish-nvm/functions/__nvm_run.fish
Line 21 in b532e73
Hi there!
Since last update of Fish to v3.2.2 this error appears:
setpgid: No such process
test: Missing argument at index 3
= Darwin
^
~/.local/share/omf/pkg/fish-nvm/functions/__nvm_run.fish (line 9):
if test (uname -s) = 'Darwin'; and string match -q "*versions/node/*/bin" $PATH
^
in function '__nvm_run' with arguments 'yarn proxy'
called on line 2 of file ~/.local/share/omf/pkg/fish-nvm/functions/yarn.fish
in function 'yarn' with arguments 'proxy'
Could not send child 19437, 'cut' in job 1, 'status stack-trace | grep called | cut -d " " -f 7' from group -1 to group 1502
setpgid: No such process
Could not send child 19439, 'which' in job 1, 'which $argv[1]' from group -1 to group 19439
setpgid: No such process
test: Missing argument at index 3
!=
^
Standard input (line 21):
if type -fq $argv[1]; and test "$stack[1]" != (which $argv[1])
^
in function 'run_command' with arguments 'yarn proxy'
called on line 68 of file ~/.local/share/omf/pkg/fish-nvm/functions/__nvm_run.fish
in function '__nvm_run' with arguments 'yarn proxy'
called on line 2 of file ~/.local/share/omf/pkg/fish-nvm/functions/yarn.fish
in function 'yarn' with arguments 'proxy'
Fish nvm: 'yarn' is currently not installed, try running npm i -g yarn
Not sure whether this is due to fish-nvm, but somehow my which
command is broken.
Welcome to fish, the friendly interactive shell
~> which git
env: node: No such file or directory
~> node
> ^D
~> which git
/usr/bin/git
~>
Not sure why this is happening - nvm
works well normally, but it's a pain to manually select a specific version every time.
A new shell starts up with a node version of 'none'.
I've manually set a default version through nvm
and verified that it works correctly in bash.
I don't have a custom $NVM_DIR
.
Hey there, first of all thanks for the great plugin ๐
This is a minor issue, but it is a bit annoying given it happens on every new prompt.
I'm using nvim, so I've added the nvm_alias_command
to my config.fish
file to have the binaries linked to my PATH.
And this is working great, with one caveat. Once the executables are created, all subsequent terminals I open have this Ignored: ... (already exists)
prints. Is there a way to suppress those?
Tks!
I can confirm the issue described in #38 happens to me as well. It's slow all the time. Type nvm install
and then hit Tab.
I have fish in two machines and either installing before or after, fish-nvm breaks https://github.com/jbonjean/re-search.
Trying to run:
nvm alias default 16.15.1
The output is:
nvm: Unknown command or option: "alias" (see nvm -h for usage)
The alias
command is not defined in the fish shell, however it is defined in zsh.
nvm -h
Usage: nvm install <version> Download and activate the specified Node version
nvm install Install version from nearest .nvmrc file
nvm use <version> Activate a version in the current shell
nvm use Activate version from nearest .nvmrc file
nvm list List installed versions
nvm list-remote List versions available to install
nvm list-remote <regex> List versions matching a given regular expression
nvm current Print the currently-active version
nvm uninstall <version> Uninstall a version
Options:
-s or --silent Suppress standard output
-v or --version Print version
-h or --help Print this help message
Variables:
nvm_arch Override architecture, e.g. x64-musl
nvm_mirror Use a mirror of the Node binaries
nvm_default_version Set the default version for new shells
nvm_default_packages Install a list of packages every time you install a Node version
I just noticed that when I start the shell, I can run node, but not gulp.
global binaries are not on the path
as soon as I run node --version
or the like, I can run gulp.
What should be the way to properly set this?
There's currently no description on how to uninstall. After removing ~/.nvm
I receive the following error:
type: Invalid combination of options
Fish nvm: 'node' is currently not installed, try running npm i -g node
Right now nvm doesn't have completions
just freshly installed this plugin through fisher
,
however when after restarting the terminal (iTerm on MacOS Mojave) and typing in nvm
, I get back:
python: can't open file '/Users/my-username/.config/fish/functions/__bass.py': [Errno 2] No such file or directory
Tried installing edc/bass
using fisher
, but still the same error (even after iTerm restart)
fisher ls
outputs:
edc/bass
FabioAntunes/fish-nvm
.config/fish/functions/
contains:
-rw-r--r-- 2 my-username staff 141 Oct 4 11:12 __can_run_command.fish
-rw-r--r-- 2 my-username staff 1078 Oct 4 11:12 __nvm_run.fish
-rw-r--r-- 2 my-username staff 479 Sep 5 01:35 bass.fish
-rw-r--r-- 1 my-username staff 14322 Oct 6 12:28 fisher.fish
-rw-r--r-- 2 my-username staff 87 Oct 4 11:12 node.fish
-rw-r--r-- 2 my-username staff 74 Oct 4 11:12 npm.fish
-rw-r--r-- 2 my-username staff 82 Oct 4 11:12 npx.fish
-rw-r--r-- 2 my-username staff 500 Oct 4 11:12 nvm.fish
-rw-r--r-- 2 my-username staff 1594 Oct 4 11:12 nvm_alias_command.fish
-rw-r--r-- 2 my-username staff 772 Oct 4 11:12 nvm_alias_function.fish
-rw-r--r-- 2 my-username staff 77 Oct 4 11:12 yarn.fish
any help much appreciated
When opening a new shell session before running any npm installed command I have to run node first:
$ echo $NVM_BIN
$ trash
fish: Unknown command 'trash'
$ npm
Now using node v6.5.0 (npm v3.10.3)
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
help, help-search, i, init, install, install-test, it, link,
list, ln, logout, ls, outdated, owner, pack, ping, prefix,
prune, publish, rb, rebuild, repo, restart, root, run,
run-script, s, se, search, set, shrinkwrap, star, stars,
start, stop, t, tag, team, test, tst, un, uninstall,
unpublish, unstar, up, update, v, version, view, whoami
npm <cmd> -h quick help on <cmd>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/matteo/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
[email protected] /Users/matteo/.nvm/versions/node/v6.5.0/lib/node_modules/npm
$ echo $NVM_BIN
/Users/matteo/.nvm/versions/node/v6.5.0/bin
$ trash
Specify at least one path
I'm not sure if its an issue with this application, but i don't know where else to start.
As i already said in the title, (not all) node and npm commands that are not quitting automatically because they are finished executing, are first logging their stuff when i quit the application with ctrl+c.
I can't reproduce the behavior with bash.
If this is the wrong place to post this, maybe you could guide me to a better place to post this.
Thanks!
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.