:earth_americas: Cross-platform support (Mac, Windows, Linux)
:sparkles: Single file, easy installation, instant startup
:sparkles: Single file, easy installation, instant startup
:rocket: Built with speed in mind
:rocket: Built with speed in mind
@ -22,13 +24,15 @@
### Using a script (MacOS/Linux)
### Using a script (MacOS/Linux)
> :wave: Hey, I'm sorry that the automated way does not support Windows yet. Feel free to contribute it! Maybe [Chocolatey](https://chocolatey.org/) or [Scoop](https://scoop.sh/)?
For `bash`, `zsh` and `fish` shells, there's an [automatic installation script](./.ci/install.sh):
For `bash`, `zsh` and `fish` shells, there's an [automatic installation script](./.ci/install.sh):
```bash
```bash
curl -fsSL https://fnm.vercel.app/install | bash
curl -fsSL https://fnm.vercel.app/install | bash
```
```
### Upgrade
#### Upgrade
On OSX, it is a simple as `brew upgrade Schniz/tap/fnm`.
On OSX, it is a simple as `brew upgrade Schniz/tap/fnm`.
- On Windows, the profile is located at `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1`
- For Mac/Linux, the profile is located at `~/.config/powershell/Microsoft.PowerShell_profile.ps1`
- For **WinCMD**, aka good old **Windows Command Prompt** or **Batch**, fnm is also supported but is not entirely covered. [You can set up a startup script](https://superuser.com/a/144348) and append the following line:
```
FOR /f "tokens=*" %i IN ('fnm env --use-on-cd') DO CALL %i
- Providing `--shell=fish` will output the Fish-compliant version. Omitting it and `fnm` will try to infer the current shell based on the process tree
- Providing `--node-dist-mirror="https://npm.taobao.org/dist"` will use the Chinese mirror of Node.js
- Providing `--fnm-dir="/tmp/fnm"` will install and use versions in `/tmp/fnm` directory
You can always use `fnm --help` to read the docs:
You can always use `fnm --help` to read the docs:
### `fnm install [VERSION]`
### `fnm install [VERSION]`
Installs `[VERSION]`. If no version provided, it will install the version specified in the `.node-version` or `.nvmrc` files located in the current working directory.
Installs `[VERSION]`. If no version provided, it will install the version specified in the `.node-version` or `.nvmrc` files located in the current working directory.
### `fnm install --lts`
Installs the latest LTS version of Node
### `fnm use [VERSION]`
### `fnm use [VERSION]`
Activates `[VERSION]` as the current Node version. If no version provided, it will activate the version specified in the `.node-version` or `.nvmrc` file located in the current working directory.
Activates `[VERSION]` as the current Node version. If no version provided, it will activate the version specified in the `.node-version` or `.nvmrc` file located in the current working directory.
#### Flags
- `--install-if-missing` — installs the version if it isn't installed yet
### `fnm current`
### `fnm current`
Display currently activated Node version.
Display currently activated Node version.
@ -123,20 +174,13 @@ Aliases a Node version to a given name.
Aliases a Node version as default. Uses `fnm alias` underneath.
Aliases a Node version as default. Uses `fnm alias` underneath.
Prints the required shell commands in order to configure your shell, Bash compliant by default.
Prints the required shell commands in order to configure your shell, Bash compliant if can't infer the shell. This command is highly influenced by [the global options](#global-options)
- Providing `--shell=fish` will output the Fish-compliant version. Omitting it and `fnm` will try to infer the current shell based on the process tree
- Providing `--node-dist-mirror="https://npm.taobao.org/dist"` will use the Chinese mirror of Node.js
- Providing `--use-on-cd` will also output a script that will automatically change the node version if a `.node-version`/`.nvmrc` file is found
- Providing `--fnm-dir="/tmp/fnm"` will install and use versions in `/tmp/fnm` directory
## Future Plans
#### Options:
- [ ] Feature: `fnm use --install`
- `--use-on-cd` will also output a script that will automatically change the node version if a `.node-version`/`.nvmrc` file is found
- [ ] Linux: Replace `tar` with a statically linked library too (for ungzip + untar)
- [ ] Windows Support? @ulrikstrid has worked hard to make it compile on Windows, but it will probably need to have different code paths and logic. We can probably make another program and share feature tests with it, instead of relying on Windows for this very-unixy binary.
## Contributing
## Contributing
@ -145,28 +189,20 @@ PRs welcome :tada:
### Developing:
### Developing:
```
```
npm install -g esy
# Install Rust
git clone https://github.com/Schniz/fnm.git
git clone https://github.com/Schniz/fnm.git
cd fnm/
cd fnm/
esy install
cargo build
esy bootstrap
esy build
```
```
### Running Binary:
### Running Binary:
After building the project, you can run the main binary that is produced.
```
```
esy x fnm.exe
cargo run -- --help # Will behave like `fnm --help`