Coder Social home page Coder Social logo

schniz / fnm Goto Github PK

View Code? Open in Web Editor NEW
15.8K 15.8K 393.0 3.79 MB

๐Ÿš€ Fast and simple Node.js version manager, built in Rust

Home Page: https://fnm.vercel.app

License: GNU General Public License v3.0

Shell 4.86% Rust 65.55% Batchfile 0.15% JavaScript 8.82% TypeScript 20.62%
hacktoberfest javascript nodejs nvm reasonml version

fnm's Introduction

Fast Node Manager (fnm) Amount of downloads GitHub Actions workflow status

๐Ÿš€ Fast and simple Node.js version manager, built in Rust

Blazing fast!

Features

๐ŸŒŽ Cross-platform support (macOS, Windows, Linux)

โœจ Single file, easy installation, instant startup

๐Ÿš€ Built with speed in mind

๐Ÿ“‚ Works with .node-version and .nvmrc files

Installation

Using a script (macOS/Linux)

For bash, zsh and fish shells, there's an automatic installation script.

First ensure that curl and unzip are already installed on you operating system. Then execute:

curl -fsSL https://fnm.vercel.app/install | bash

Upgrade

On macOS, it is as simple as brew upgrade fnm.

On other operating systems, upgrading fnm is almost the same as installing it. To prevent duplication in your shell config file add --skip-shell to install command.

Parameters

--install-dir

Set a custom directory for fnm to be installed. The default is $XDG_DATA_HOME/fnm (if $XDG_DATA_HOME is not defined it falls back to $HOME/.local/share/fnm on linux and $HOME/Library/Application Support/fnm on MacOS).

--skip-shell

Skip appending shell specific loader to shell config file, based on the current user shell, defined in $SHELL. e.g. for Bash, $HOME/.bashrc. $HOME/.zshrc for Zsh. For Fish - $HOME/.config/fish/conf.d/fnm.fish

--force-install

macOS installations using the installation script are deprecated in favor of the Homebrew formula, but this forces the script to install using it anyway.

Example:

curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "./.fnm" --skip-shell

Manually

Using Homebrew (macOS/Linux)

brew install fnm

Then, set up your shell for fnm

Using Winget (Windows)

winget install Schniz.fnm

Using Scoop (Windows)

scoop install fnm

Then, set up your shell for fnm

Using Chocolatey (Windows)

choco install fnm

Then, set up your shell for fnm

Using Cargo (Linux/macOS/Windows)

cargo install fnm

Then, set up your shell for fnm

Using a release binary (Linux/macOS/Windows)

Removing

To remove fnm (๐Ÿ˜ข), just delete the .fnm folder in your home directory. You should also edit your shell configuration to remove any references to fnm (ie. read Shell Setup, and do the opposite).

Completions

fnm ships its completions with the binary:

fnm completions --shell <SHELL>

Where <SHELL> can be one of the supported shells:

  • bash
  • zsh
  • fish
  • power-shell

Please follow your shell instructions to install them.

Shell Setup

Environment variables need to be setup before you can start using fnm. This is done by evaluating the output of fnm env. To automatically run fnm use when a directory contains a .node-version or .nvmrc file, add the --use-on-cd option to your shell setup.

Adding a .node-version to your project is as simple as:

$ node --version
v14.18.3
$ node --version > .node-version

Check out the following guides for the shell you use:

Bash

Add the following to your .bashrc profile:

eval "$(fnm env --use-on-cd)"

Zsh

Add the following to your .zshrc profile:

eval "$(fnm env --use-on-cd)"

Fish shell

Create ~/.config/fish/conf.d/fnm.fish add this line to it:

fnm env --use-on-cd | source

PowerShell

Add the following to the end of your profile file:

fnm env --use-on-cd | Out-String | Invoke-Expression
  • For macOS/Linux, the profile is located at ~/.config/powershell/Microsoft.PowerShell_profile.ps1
  • On Windows to edit your profile you can run this in a PowerShell
    notepad $profile

Windows Command Prompt aka Batch aka WinCMD

fnm is also supported but is not entirely covered. You can set up a startup script and append the following line:

FOR /f "tokens=*" %i IN ('fnm env --use-on-cd') DO CALL %i

โš ๏ธ If you get the error i was unexpected at this time, please make a .cmd file as suggested by the first step in the Usage with Cmder secton add it's path to the AutoRun registry key.

Usage with Cmder

Usage is very similar to the normal WinCMD install, apart for a few tweaks to allow being called from the cmder startup script. The example assumes that the CMDER_ROOT environment variable is set to the root directory of your Cmder installation. Then you can do something like this:

  • Make a .cmd file to invoke it
:: %CMDER_ROOT%\bin\fnm_init.cmd
@echo off
FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd') DO CALL %%z
  • Add it to the startup script
:: %CMDER_ROOT%\config\user_profile.cmd
call "%CMDER_ROOT%\bin\fnm_init.cmd"

You can replace %CMDER_ROOT% with any other convenient path too.

See the available commands for an extended usage documentation

Contributing

PRs welcome ๐ŸŽ‰

Developing:

# Install Rust
git clone https://github.com/Schniz/fnm.git
cd fnm/
cargo build

Running Binary:

cargo run -- --help # Will behave like `fnm --help`

Running Tests:

cargo test

fnm's People

Contributors

alexmunoz avatar amitdahan avatar aquacash5 avatar armaldio avatar dependabot[bot] avatar dnaka91 avatar elliottsj avatar github-actions[bot] avatar jameschensmith avatar jaythomas avatar leafrogers avatar loliee avatar lorensr avatar lucasweng avatar matthieubosquet avatar maxjacobson avatar maxknee avatar megamannen avatar mpthlee avatar pavelloz avatar pckilgore avatar pfiaux avatar renovate[bot] avatar scadu avatar schniz avatar tatchi avatar thomsj avatar ulrikstrid avatar vladimyr avatar waldyrious 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  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

fnm's Issues

Alias support

fnm alias v8.11.3 my-name

fnm use my-name # like `fnm alias v8.11.3`

After that, we can make #6 happen (by having an alias of system to the system's node ๐Ÿ˜„)

Allow downloading versions from a Node.js mirror

This is a feature request.

When I already have ~/.fnm/downloads/v11.9.0.tar.xz exists on disk, if I run fnm install 11.9.0, I would like fnm to try to unarchive it first and starting to download the fresh package only if unarchive exits with none zero status.

I use Taobao's node dist mirror. It's faster than Nodejs's 1st party one since I'm in China.(Taobao is a Alibaba company)

As a example:

# I use this url
https://npm.taobao.org/dist/v11.9.0/node-v11.9.0-darwin-x64.tar.xz
# instead of
https://nodejs.org/dist/v11.9.0/node-v11.9.0-darwin-x64.tar.xz

Mac OS command not found

Mac OS, if I'm not wrong, by default running .bash_profile before opening new terminal window, so when I installed fnm via curl i need to copy those lines from .bashrc to .bash_profile:
export PATH=$HOME/.fnm:$PATH eval fnm env --multi

don't know if it's really a problem but it took me little digging why fnm command not found..

Add support for .node-version files

Most version managers support the .node-version format:

Tool Name Config File Plattform Notes
nvs .node-version Mac / Linux / Windows ย 
nvm .nvmrc Mac / Linux
nodenv .node-version Mac / Linux ย 
nodist .node-version Windows ย 
avn .node-version Mac / Linux ย 
n ย  Mac / Linux Does not seem to have a config file option

Could you please also add support?

When a version does not exist, fnm exists with status code 0

After using fnm install I got an informative message Version v8 not found! It said that the task was not sucessfull, but It would be better if the color would be red.

I also expected the status code for unsuccessful oparation to be 1 instead of 0.

image

fnm install fails if target Node version already exists

Issue:

fnm install only works when the Node version specified in the command (or .nvmrc) is not already present on the machine.

Steps:

  1. fnm install <some version>
  2. fnm use <same version as above>
  3. fnm install <same version as above>

Error:
Macbook Pro - 10.13.3 (High Sierra)

[17:34:26]: some-project $ fnm install v11.9.0
Looking for node v11.9.0 for darwin x64
Downloading https://nodejs.org/dist/v11.9.0/node-v11.9.0-darwin-x64.tar.xz to /Users/user/.fnm/downloads/v11.9.0.tar.xz
Extracting /Users/user/.fnm/downloads/v11.9.0.tar.xz to /Users/user/.fnm/node-versions/v11.9.0
fnm: internal error, uncaught exception:
     Unix.Unix_error(Unix.ENOTEMPTY, "rename", "/Users/user/.fnm/node-versions/v11.9.0/node-v11.9.0-darwin-x64")
     Raised by primitive operation at file "src/unix/lwt_unix.cppo.ml", line 235, characters 14-31
     Re-raised at file "executable/Install.re", line 75, characters 2-104
     Re-raised at file "src/core/lwt.ml", line 2987, characters 20-29
     Called from file "src/unix/lwt_main.ml", line 26, characters 8-18
     Called from file "cmdliner_term.ml", line 25, characters 19-24
     Called from file "cmdliner.ml", line 116, characters 32-39

Use Case:
To ensure the same version of Node is used on all of my build servers, I'd like to add the fnm install and fnm use commands to my build pipeline. Updating the Node version in a repository's .nvmrc is much easier than manually updating each build server ๐Ÿ˜

Fix Linux build

for some reason, #64 fails on Linux although there are no changes to any of the files.
Maybe it's time to fixate on versions (instead of using *), or just see what's going on in the .ci/shasum script (maybe for some packages it uses a different algorithm?)

fnm use loudness

2 lines seems very verbose with message that looks like a debug info:

Linking /Users/Pavel/.fnm/current to /Users/Pavel/.fnm/node-versions/v10.15.1/installation
Using v10.15.1

Maybe something like:

fnm using node v10.15.1 would be enough as default?

`fnm install` not working on Fedora 29 and Gentoo

$ curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3109  100  3109    0     0   8290      0 --:--:-- --:--:-- --:--:--  8290
Checking dependencies for the installation script...
Checking availablity of curl... OK!
Checking availablity of unzip... OK!
Downloading https://github.com/Schniz/fnm/releases/download/v1.2.1/fnm-linux.zip...
######################################################################## 100.0%
Installing for Zsh. Appending the following to /home/kweis/.zshrc:

  # fnm
  export PATH=$HOME/.fnm:$PATH
  eval `fnm env`

In order to apply the changes, open a new terminal or run the following command:

  source /home/kweis/.zshrc
$ export PATH=$HOME/.fnm:$PATH
$ eval `fnm env`
$ fnm install 10
Looking for node v10 for linux x64
Version exists, but can't find a file for your system:
  OS:           linux
  Architecture: x64
$ fnm ls
No versions installed!

Any idea?

1.6 killed error

Hello. I'm Working on centos 6 atm. 1.5 works fine but when i upgraded to 1.6 or 1.6.1 i get a Killed Error when i try to use any command. 1.6.1 also works on my ubuntu setup at home so i'm guessing this is a centos specific issue.

internal error, uncaught exception

I've been getting this error when running NPM lately:

fnm: internal error, uncaught exception:
     Unix.Unix_error(Unix.EEXIST, "symlink", "/Users/daniel/.fnm/node-versions/v11.10.0/installation")
     Raised by primitive operation at file "src/unix/lwt_unix.cppo.ml", line 235, characters 14-31
     Re-raised at file "executable/Use.re", line 43, characters 2-434
     Re-raised at file "src/core/lwt.ml", line 2987, characters 20-29
     Called from file "src/unix/lwt_main.ml", line 26, characters 8-18
     Called from file "cmdliner_term.ml", line 25, characters 19-24
     Called from file "cmdliner.ml", line 116, characters 32-39

`fnm use` fails if node version doesn't exist

Similar to #11, running fnm use when no node versions have been installed results in the same unfriendly error message and 125 error code:

$ fnm use
fnm: internal error, uncaught exception:
     Unix.Unix_error(Unix.ENOENT, "opendir", "/Users/<username>/.fnm/node-versions")
     Raised by primitive operation at file "src/unix/lwt_unix.cppo.ml", line 235, characters 14-31
     Re-raised at file "library/Fs.re", line 5, characters 2-441
     Re-raised at file "library/Versions.re", line 38, characters 4-262
     Re-raised at file "library/Versions.re", line 294, characters 2-497
     Re-raised at file "executable/Use.re", line 15, characters 2-1023
     Re-raised at file "src/core/lwt.ml", line 2987, characters 20-29
     Called from file "src/unix/lwt_main.ml", line 26, characters 8-18
     Called from file "cmdliner_term.ml", line 25, characters 19-24
     Called from file "cmdliner.ml", line 116, characters 32-39
$ echo $?
125

As a user I'd expect fnm use to install the version in case it didn't exist before. Please forgive if this is intended as my expectations come from using nvm before ๐Ÿ˜; in such case, providing a friendlier message and pointing to fnm install would help.

Zero exit code on error

Steps to reproduce:

โžœ fnm use v9.11.1
The following version is not installed: v9.11.1
โžœ echo $?
0

Expected behavior:

โžœ fnm use v9.11.1
The following version is not installed: v9.11.1
โžœ echo $?
1

Where the return code 1 is just a placeholder for whatever exit code you would implement.

fnm doesn't swap out the correct version of node

I'm a little confused by the result. I'm expecting for node 8 to show up but it doesn't look like that's the case.

C02V51K4HTD7:client william.gottschalk$ fnm --version
1.0.0

C02V51K4HTD7:client william.gottschalk$ fnm install 8.11.2
Looking for node v8.11.2 for darwin x64
Downloading https://nodejs.org/dist/v8.11.2/node-v8.11.2-darwin-x64.tar.gz to /Users/william.gottschalk/.fnm/downloads/v8.11.2.tar.gz
Extracting /Users/william.gottschalk/.fnm/downloads/v8.11.2.tar.gz to /Users/william.gottschalk/.fnm/node-versions/v8.11.2

C02V51K4HTD7:client william.gottschalk$ fnm use 8.11.2
Linking /Users/william.gottschalk/.fnm/current to /Users/william.gottschalk/.fnm/node-versions/v8.11.2/installation
Using v8.11.2

C02V51K4HTD7:client william.gottschalk$ node -v
v11.2.0

C02V51K4HTD7:client william.gottschalk$ which node
/Users/william.gottschalk/.fnm/current/bin/node

I have nvm installed on my machine but I'm not executing any of the start up scripts to activate it.

Problems with installation

When I run the following curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash -s --skip-shell, I get the following error:

bash: --: invalid option
Usage:	bash [GNU long option] [option] ...
	bash [GNU long option] [option] script-file ...
GNU long options:
	--debug
	--debugger
	--dump-po-strings
	--dump-strings
	--help
	--init-file
	--login
	--noediting
	--noprofile
	--norc
	--posix
	--protected
	--rcfile
	--restricted
	--verbose
	--version
	--wordexp
Shell options:
	-irsD or -c command or -O shopt_option		(invocation only)
	-abefhkmnptuvxBCHP or -o option
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3650  100  3650    0     0   5182      0 --:--:-- --:--:-- --:--:--  5184
(23) Failed writing body

But, if I run curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash, it works fine

Share global packages per major node version

Can't remember in detail how nvm handles this (painfully, I think).

But I was wondering if we could make fnm share the global modules within the same node major version, for example, if I use fnm install 10 to upgrade v10.14.2 -> v10.15.1 -> v10.15.2 -> v10.15.3, it would be cool if the global packages would continue working. Only if you switch to a different major, say 11, should you get a separate stash of globals.

What do you think? Worth exploring?

Multi-shell support

I believe this can be a breaking change, therefore should mark a version 2?

In its core, the following thing should work:

bash 1            | bash 2       
------------------|-------------
$ fnm use 11.0.0  |
Using Node 11.0.0 |
                  | $ fnm use 10.0.0
                  | Using Node 10.0.0
$ node -v         | $ node -v
11.0.0            | 10.0.0

How would that work?

I guess we can create a directory in /tmp, that will contain symlinks. A symlink will be created every time we call fnm env! The system will clean it up itself, so there is no problem there:

$ fnm env
export PATH=/tmp/fnm_environments/terminal_xxyyzz:$PATH

This may relate also to #6, because we might have to implement some kind of "aliases". This shouldn't be hard as well because - it's also a symlink. Isn't that great? Everything is a symlink!

Feature requests / wishlist

thanks for the great version manager first of all!
just a list of features i'd like to have in an upcoming release ๐Ÿ˜„

features

  • fnm uninstall <version>
  • fnm default <version> to set a default version
  • auto select right node version if .nvmrc .node-version file exists (sry it's already in progress #68 ๐Ÿ‘€ )

thanks again ๐Ÿ˜„

Use `engines` in modules where it is defined

There's a package.json property called engines. This property can be used for anything, but one of the few defined engines is node. It's extremely unfortunate that it's not been used in tooling like fnm yet, and would be incredible to see fnm adopt it as a version indicator.

The added complexity here will be around version ranges, since semver ranges are entirely within scope for this field.

Ideally, it would be absolutely incredible if I could run fnm inside of a directory with the engines property defined and be presented with my options.

  • Show a row for each acceptable release line
    • Prioritize the versions I've already got installed that match those releases
    • Show (via green/red text) if I don't have any versions installed that match the range and offer to install if I want to use that release line

Engines documentation in the npm-package.json docs: https://docs.npmjs.com/files/package.json#engines

Installing from fish via Homebrew

When I ran brew install Schniz/tap/fnm I got the following "caveat":

Skipped the installation of fnm to ~/.config/fish/config.fish because I found `# fnm`.
In case you want to do it manually, add the following to the file:

  # fnm
  eval "$(fnm env --multi)"

I did not have that in my config.fish previously, so it was definitely added during installation. However, this isn't the correct syntax for fish and will break the config. It should be fnm env --multi | source, right?

`fnm use` doesn't switch node version

Hi,

With a clean install of fnm 1.9.0 and fish shell version 3.0.2, the fnm use command doesn't work as expected.

steps to reproduce

$ fnm install v8.10.0
$ fnm use v8.10.0
$ fnm alias v8.10.0 default

fnm ls is just fine

$ fnm ls
The following versions are installed:
* v8.10.0 (default)

And Testing node version gives the expected output

$ node --version
v8.10.0

Now installing latest LTS 10.15.3 and trying to switch to that version is not working

fnm install v10.15.3
fnm use v10.15.3

Again, fnm ls says that everything is fine

$ fnm ls
The following versions are installed:
* v8.10.0 (default)
* v10.15.3

(with a blue-green highlight on the 10.15.3 version indicating it's the current version)

However node version is still 8.10.0

$ node --version
v8.10.0

Additional information

I've tried to locate which version is pointing the node symbolic link to:

$ which node
/tmp/fnm-shell-2857505/bin/node

And /tmp/fnm-shell-2857505 is linking /tmp/fnm-shell-2857505 -> /home/spiroid/.fnm/aliases/default/ which seems to be the issue here, as i guess it should link /home/spiroid/.fnm/current/ right ?

Thanks for your help

Problems with installing with `--skip-shell` flag

When I run curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash -s --skip-shell, I get the following error:

bash: --: invalid option
Usage:	bash [GNU long option] [option] ...
	bash [GNU long option] [option] script-file ...
GNU long options:
	--debug
	--debugger
	--dump-po-strings
	--dump-strings
	--help
	--init-file
	--login
	--noediting
	--noprofile
	--norc
	--posix
	--protected
	--rcfile
	--restricted
	--verbose
	--version
	--wordexp
Shell options:
	-irsD or -c command or -O shopt_option		(invocation only)
	-abefhkmnptuvxBCHP or -o option
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3650  100  3650    0     0   5182      0 --:--:-- --:--:-- --:--:--  5184
(23) Failed writing body

However, if I just run curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash, it works fine

Fish completions

Are there any plans for adding fish completions? Perhaps this could be achieved with a man page, as it would probably be better than having third-party completions from, for example, an Oh My Fish plugin. Maybe the installation script could add completions to ~/.config/fish/completions, as this could allow for completions similar to plugin-nvm.

Have you thought about being able to install node local to a project?

So in a lot of my projects I put a ./appw file that will start the app from absolute scratch even if you don't have node or nvm installed anywhere. It is kind of janky because nvm was not built to do this. Have you ever considered adding a supported mode where you could install fnm local to a project directory and install node versions alongside it?

psuedo code script example

#install fnm
curl -0 .fnm/bin/fnm ...
export PATH=`pwd`/.fnm/bin:$PATH
fnm install # via package.json
fnm use
export PATH=`pwd`/.fnm/node-versions/${NODE_VERSION} #some way to get this from .nvmrc?
if [ ! -d 'node_modules' ]; then # you can also use the hash of the package.json file to check
  npm install
fi
exec npm start || node app/index.js || ts-node app/index.ts

Installation script failure in WSL bash

Using the install script with flags causes the installation script to fail in WSL ubuntu 18.04.

curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash --install-dir "/home/user/.local/bin" --skip-shell
bash: --install-dir: invalid option
Usage:  bash [GNU long option] [option] ...
        bash [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option

Tests: use another Node.js mirror

Taobao (Chinese Node.js mirror) is making our tests flakey and slow.
I guess we can setup a simple server to something like netcat and proxy all requests to nodejs, making it a proxy instead of a mirror, but that acts the same?
maybe drop the test or something?

Replace `curl`

Use an OCaml replacement or a statically linkable library, instead of spawning a subprocess. Need to verify that it works on a plain Mac (there is no static link process for MacOS, AFAIK)

  • cohttp{,-lwt} with ssl_lwt?
  • ocurl?
  • httpkit? (cc @thangngoc89)

Infer shell type in `fnm env`

We can use $SHELL to see if we have fish or anything else, which we assume is bash compliant for now ๐Ÿ˜ธ:

$ echo $SHELL
/bin/zsh

_fnm_autoload_hook:4: command not found: elsif

I just modified my .zshrc to add --use-on-cd.

# fnm
export PATH=$HOME/.fnm:$PATH
eval "`fnm env --multi --use-on-cd`"

It worked but with an error when I cd into a dir with a node version file:

โฏ cd /myprojectwith.node-version-in-it
fnm: Found .node-version
Linking /var/folders/x_/wwvkzdz104n7j0m5jj2dq06m0000gn/T/fnm-shell-1852363 to /Users/moox/.fnm/node-versions/v8.10.0/installation
Using v8.10.0
_fnm_autoload_hook:4: command not found: elsif

Last line looks like an error.

I am using latest macOS beta with zsh 5.3 (x86_64-apple-darwin18.0)

Allow using the system version of node

nvm allows to use the system version of node and npm (if installed). Having this feature in fnm will be awesome.

$ fnm use system

Also, maybe $ fnm ls should also list the system version.

Exit 125 when `~/.fnm/node-versions` does not exist

If you run fnm ls before installing any versions, you get an error since ~/.fnm/node-versions has not been created.

$ fnm ls
fnm: internal error, uncaught exception:
     (Failure "/Users/xxx/.fnm/node-versions: No such file or directory")
     Raised at file "executable/ListLocal.re", line 6, characters 6-554
     Re-raised at file "src/core/lwt.ml", line 2987, characters 20-29
     Called from file "src/unix/lwt_main.ml", line 26, characters 8-18
     Called from file "cmdliner_term.ml", line 25, characters 19-24
     Called from file "cmdliner.ml", line 116, characters 32-39
$ echo $?
125

Install is failing on unzip

curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3649  100  3649    0     0   6747      0 --:--:-- --:--:-- --:--:--  6757
Checking dependencies for the installation script...
Checking availablity of curl... OK!
Checking availablity of unzip... OK!
Downloading https://github.com/Schniz/fnm/releases/download//fnm-macos.zip...
######################################################################## 100.0%
[/var/folders/4w/6430rhmd1td4p_c564bzpjxmlhrhc3/T/tmp.ATFeAgaY/fnm-macos.zip]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /var/folders/4w/6430rhmd1td4p_c564bzpjxmlhrhc3/T/tmp.ATFeAgaY/fnm-macos.zip or
        /var/folders/4w/6430rhmd1td4p_c564bzpjxmlhrhc3/T/tmp.ATFeAgaY/fnm-macos.zip.zip, and cannot find /var/folders/4w/6430rhmd1td4p_c564bzpjxmlhrhc3/T/tmp.ATFeAgaY/fnm-macos.zip.ZIP, period.

image

Wrong filename in v1.2.0 Linux archive

I tried to install fnm on my ubuntu, but when I executed the install command (curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash) I had the following error:

mv: impossible d'รฉvaluer '/tmp/tmp.Op2bPEFVJX/fnm-linux/fnm': Aucun fichier ou dossier de ce type

My system is in french, but it means that /tmp/tmp.Op2bPEFVJX/fnm-linux/fnm doesn't exist. It is because the bin contained in the fnm-linux.zip archive is not named fnm, but fnm-linux:

ll /tmp/tmp.Op2bPEFVJX/fnm-linux/
total 14M
-rw-r--r-- 1 drazik drazik 14M janv. 30 13:49 fnm-linux

Since the file in the macOS archive is named fnm, I assume this is just a mistake while packing the Linux archive.

I easily worked around this issue by forking the repository and updating .ci/install.sh

-  mv $DOWNLOAD_DIR/$FILENAME/fnm $HOME/.fnm/fnm
+  mv $DOWNLOAD_DIR/$FILENAME/$FILENAME $HOME/.fnm/fnm

But I just wanted to let you know that there is an issue preventing from installing fnm by just running the command in the README on Linux ;)

EDIT: actually I just looked at other release, it seems that this is like this from the beginning.

Automatic installation script fails

Hello!

In my ongoing research for a fast, reliable Node Version Manager I came across your project and wanted to check it out!

When I tried to run the automatic installation script, I got this error:

โฏ curl https://raw.githubusercontent.com/Schniz/fnm/master/.ci/install.sh | bash
######################################################################## 100.0%
Checking dependencies for the installation script...
Checking availablity of curl... OK!
Checking availablity of unzip... OK!
Downloading https://github.com/Schniz/fnm/releases/download/## โœจ Highlight โœจ \r\n\r\nInference of complete semantic version:\r\n\r\nIn order to download the latest Node 11 version:\r\n\r\n```bash\r\nfnm install 11\r\n```\r\n\r\nIn order to use the latest installed Node 11 version:\r\n\r\n```bash\r\nfnm use 11\r\n```\r\n\r\n## All contributions ๐Ÿ‘ ๐ŸŒฎ \r\n\r\n#### New Feature ๐ŸŽ‰\r\n\r\n- [#60](https://github.com/Schniz/fnm/pull/60) Disable colors for non-tty devices ([@Schniz](https://github.com/Schniz))\r\n- [#48](https://github.com/Schniz/fnm/pull/48) Add parameters to the install script, enabling custom installs (`--install-dir` and `--skip-shell`) ([@from-nibly](https://github.com/from-nibly))\r\n- [#54](https://github.com/Schniz/fnm/pull/54) Infer complete semver (`vX.X.X`) out of partial input (`vX`/`vX.X`). ([@Schniz](https://github.com/Schniz))\r\n\r\n#### Bugfix ๐Ÿ›\r\n\r\n- [#58](https://github.com/Schniz/fnm/pull/58) Adding check for OSX during writing for bash shell ([@maxknee](https://github.com/maxknee))\r\n- [#56](https://github.com/Schniz/fnm/pull/56) Correct status code on `install` failures ([@ranyitz](https://github.com/ranyitz))\r\n\r\n#### Internal ๐Ÿ› \r\n\r\n- [#55](https://github.com/Schniz/fnm/pull/55) Make tests faster by using cnpmjs as Node.js mirror in tests ([@Schniz](https://github.com/Schniz))\r\n\r\n#### Documentation ๐Ÿ“\r\n\r\n- [#49](https://github.com/Schniz/fnm/pull/49) Add a `--fnm-dir` option to `fnm env` ([@Schniz](https://github.com/Schniz))\r\n- [#50](https://github.com/Schniz/fnm/pull/50) Added CHANGELOG ([@Schniz](https://github.com/Schniz))/fnm-macos.zip...

Looks like the script fails when parsing the tag_name of the latest release, possibly because the JSON returned by GitHub API is a one-liner, and grep + sed cannot parse the tag value.

Yarn support?

Is there any plan on the roadmap to support yarn? I can npm i -g yarn but then any packages I install globally through yarn global add aren't linked to fnm's global bin path. Is there a workaround so I can install global packages through yarn and not have them persist when changing node versions with fnm?

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.