Giter Site home page Giter Site logo

nvm.fish's People

Contributors

briancavalier avatar eugenetriguba avatar fabioantunes avatar franciscolourenco avatar jorgebucaran avatar kallja avatar kidonng avatar klapouchy avatar klesh avatar ktamas avatar myw avatar ngryman avatar raulrpearson avatar ryanq avatar saintwinkle avatar tomyun avatar vincentbel avatar wesbaker avatar yohanboniface avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvm.fish's Issues

Yarn support?

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?

First time running fnm: I couldn't find '6.11.3' in the version index.

$ 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.

Issues after clean install

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:
lardissone 2017-01-21 12-01-03

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:
fnmtest 2017-01-21 12-08-41

Any idea? Is there a way to debug the error?

`nvm use` (with no arguments) as alias for `nvm`?

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?

Getting pna.nextTick is not a function with node 8.12.0

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.

Add nvm current command

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.

fnm <version> always installs .config/fnm/lib/node_modules/npm/bin/npm-cli.js v5.6.0

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

Document about removing versions

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?

Support Node.js LTS aliases

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.

Do not change fish_user_paths

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.

"nvm use" should get version from .nvmrc

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: ""

nvm compat issues

I just installed this package to hopefully have an improved nvm experience with Fish shell...

Here's what I discovered:

Native nvm compat issues:

  1. nvm current doesn't exist, in native nvm the current flag will list the current active Node.js version in use.
  2. nvm ls-remote doesn't exist, in native nvm the ls-remote flag will list the available Node.js versions that can be installed
  3. nvm 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:

  1. 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 year
  2. Running nvm use lts installs the latest v12.x release, I expected it to install the latest v10.x release

npm issues:

  1. Installing 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
  2. Having the path as ~/.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.

Listing installed node versions

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?

__fish_not_contains_opt

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

Filter available versions shown with ls

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?

Should node use nearest parent .node-version file?

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?

npm ERR! Cannot find module 'internal/util/types'

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

Revisit $fish_user_paths usage

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

always installs latest version

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

BSD support

Looks like you're checking for the OS here:

https://github.com/fisherman/fnm/blob/503b07d3b419908409373699c227c4baf32b4b7b/functions/__fnm_version_download.fish#L6-L23

Also, this code isn't putting out an error for me:

https://github.com/fisherman/fnm/blob/503b07d3b419908409373699c227c4baf32b4b7b/functions/__fnm_use.fish

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!

This seems like a downgrade in usability compared to fnm :((

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 :(

MSYS2 (Windows) support

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

Migrate nvm dir from XDG_CONFIG_HOME to XDG_DATA_HOME

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.

Version switching not working

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:

image

lts version issue

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.

.nvmrc should be searched by traversing the directory tree up

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

See NVM

Breaking: Rewrite

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.

npm not present?

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?

update npm

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

Consider not overwriting .nvmrc when using it

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?

Just wanted to thank you

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. 👌

Modify path for the current session only

👋

What's the problem?

  • I have a bunch of fish scripts that run in the background and use system-wide installation of node. Global modification of PATH breaks them.
  • I have different projects I work in parallel that use different node versions. Modification of fish_user_paths affects all terminal sessions, therefore, all projects.
  • I want to write a wrapper around 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

  • Make path modification behavior configurable through a variable. If the user chooses to, do not modify universal 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

Can't use with VSCode

I'm just now trying out fnm. It seems to work great, except I'm not able to use this in conjunction with VSCode. It seems like the issue revolves around the fact that fnm overwrites the node executable with a fish function.

Here's the error that I get:

screen shot 2018-02-05 at 11 39 54 am

Throwing errors when switching directories with .nvmrc set to uninstalled version

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

Invalid version number or alias

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!

[Bug] copy `symlink` failed cause npm/npx not updated after `fnm use x`

Thanks for this great tool, love the fish native way instead of mess with nvm/bass.

Issue

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".

Impact

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.

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.