# n-install **Repository Path**: codeyhj_admin/n-install ## Basic Information - **Project Name**: n-install - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-10 - **Last Updated**: 2024-12-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mklement0/n-install/blob/master/LICENSE.md) **Contents** - [n-install — introduction](#n-install-mdash-introduction) - [Examples](#examples) - [Installing n](#installing-n) - [Installation from GitHub](#installation-from-github) - [Manual installation](#manual-installation) - [Installation options](#installation-options) - [Updating n](#updating-n) - [Manual updating](#manual-updating) - [Uninstalling n](#uninstalling-n) - [Manual uninstallation](#manual-uninstallation) - [License](#license) - [Acknowledgements](#acknowledgements) - [npm dependencies](#npm-dependencies) - [Changelog](#changelog) # n-install — introduction **Installs [`n`](https://github.com/tj/n)**, the **[Node.js](https://nodejs.org/) version manager**, on Unix-like platforms, **without needing to install Node.js first**. Additionally, installs scripts `n-update` for later on-demand updating of `n`, and `n-uninstall` for uninstalling. The simplest case is **installation of `n` with confirmation prompt**, with subsequent **installation of the latest LTS Node.js version**: ```shell curl -L https://bit.ly/n-install | bash ``` This is by far **the simplest way to get started with both `n` and Node.js** - even if you're looking to install only the latest LTS (long-term support) Node.js version, with no (immediate) plans to install _multiple_ versions. `n` is installed as follows: * The installation target is a **dedicated directory**, which **defaults to `~/n`** and can be overridden with environment variable `N_PREFIX`; n itself as well as the active Node.js version are placed there. * When overriding, it is advisable to choose a user location - typically, a subfolder of `~` (at any level) - so as to avoid the need to use `sudo` for installation of global `npm` packages. * Either way, the target directory must either not exist yet or be empty. * Using a dedicated directory to hold both `n` and the Node.js versions greatly simplifies later uninstallation. * If your shell (your default interactive shell, as reflected in environment variable `$SHELL`) is **`bash`, `ksh`, `zsh`, `fish`, or `pwsh` (PowerShell), the relevant shell initialization file is modified**: * Environment variable `N_PREFIX` is defined to point to the installation directory. * Directory `$N_PREFIX/bin` is appended to the `$PATH`, unless already present. * For other shells, these modification must be performed manually; instructions are provided during installation. * NoteL You can also suppress modification with the `-n` option. * **Note**: If you want to override what shell's initialization file is updated, set the `SHELL` environment variable to that shell's file name (e.g., `fish`) before calling the installation command; e.g., from a POSIX-compatible shell: `curl -L https://bit.ly/n-install | SHELL=fish bash`; similarly, on uninstallation you'll have to use `SHELL=fish n-uninstall` * By default, the latest LTS Node.js version is installed; you can suppress that or even specify multiple Node.js versions to install. * Note that any preexisting `n`, Node.js installation must be removed before using this installation method. * All installation prerequisites are met by default on macOS and some Linux distros; notably, `git` and `curl` must be present - see [Installing n](#installing-n) for details. * After installation, **be sure to open a new terminal tab or window or reload your shell initialization file** before attempting to use `n` / Node.js. See examples [below](#examples), and [Installing n](#installing-n) for prerequisites and installation options. # Examples See [Installation options](#installation-options) for details. * Installation with confirmation prompt to default location `$HOME/n` and installation of the latest LTS Node.js version: ```shell curl -L https://bit.ly/n-install | bash ``` * Automated installation to default location `$HOME/n` and installation of the latest LTS Node.js version: ```shell curl -L https://bit.ly/n-install | bash -s -- -y ``` * Automated, _quiet_ installation to default location `$HOME/n` and installation of the latest LTS Node.js version; _no status information_ is displayed: ```shell curl -sL https://bit.ly/n-install | bash -s -- -q ``` * Automated installation to the default location, with subsequent installation of the latest LTS (Long Term Support) version, and the latest 0.10.x release: ```shell curl -L https://bit.ly/n-install | bash -s -- -y lts 0.10 ``` * Automated installation to custom location `~/util/n`, with subsequent installation of the latest LTS Node.js version: ```shell curl -L https://bit.ly/n-install | N_PREFIX=~/util/n bash -s -- -y ``` # Installing n **Supported platforms and prerequisites** Among the platforms supported by `n`, any Unix-like platform with the following is supported: * [`bash`](http://www.gnu.org/software/bash/) * [`curl`](http://curl.haxx.se/) * [`git`](http://git-scm.com/) * [GNU `make`](http://www.gnu.org/software/make/) These prerequisites are met by default on macOS and on at least some Linux platforms. What's missing from some by default is `git` and/or `curl`, which, however, are easy to install from the respective package managers (e.g., `sudo apt-get install git curl` on Debian, or `sudo yum install git` on Fedora). `bash` and `curl` are required by `n` itself as well. Irrespective of the installation method chosen below, no further steps are required if your default shell is either **`bash`, `ksh`, `zsh`, `fish`, or `pwsh` (PowerShell)**. For other shells, manual updating of the relevant initialization file is required; detailed instructions are provided during installation. ## Installation from GitHub ```shell curl -L https://bit.ly/n-install | [N_PREFIX=] bash [-s -- [-y] [...]] ``` See below for an explanation of the options; `-s --` is required by Bash itself in order to pass options through to the script piped from stdin. **Before you can use `n` and any installed Node.js versions**, you must **open a new terminal tab/window _or_ reload your shell initialization file**. For instance, if your shell is Bash and you're on **Linux**, you'd use **`. ~/.bashrc`**; on **macOS**, you'd use **`. ~/.bash_profile`**; the installer will tell you the specific file to reload on successful installation. _Caveat_: If you **reload the initialization file from a _script_** (rather than interactively) - so that you can make use of `n` or Node.js in the remainder of the script, e.g., in order to preinstall global npm packages - **make sure that you account for initialization files that prevent (re)sourcing from a _non-interactive_ shell**. For instance, **Debian** and **Ubuntu** come with a default `~/.bashrc` file that - needlessly - categorically prevents sourcing (loading) if the shell is not interactive, using the following line at the start of the script: `[ -z "$PS1" ] && return` To bypass that: * In `bash`, precede the reload (sourcing) command with `set -i` to simulate an interactive environment: set -i # turn on interactive mode . ~/.bashrc # reload (source) the initialization file set +i # turn interactive mode back off * Alternatively, invoke your script as a whole with `bash --norc --noprofile -i