|
| 1 | +[](https://github.com/mklement0/n-install/blob/master/LICENSE.md) |
| 2 | + |
| 3 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 4 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 5 | + |
| 6 | +**Contents** |
| 7 | + |
| 8 | +- [n-install — introduction](#n-install-&mdash-introduction) |
| 9 | +- [Examples](#examples) |
| 10 | +- [Installing n](#installing-n) |
| 11 | + - [Options and background information](#options-and-background-information) |
| 12 | +- [Updating n](#updating-n) |
| 13 | + - [Manual updating](#manual-updating) |
| 14 | +- [Uninstalling n](#uninstalling-n) |
| 15 | + - [Manual uninstallation](#manual-uninstallation) |
| 16 | +- [License](#license) |
| 17 | + - [Acknowledgements](#acknowledgements) |
| 18 | + - [npm dependencies](#npm-dependencies) |
| 19 | +- [Changelog](#changelog) |
| 20 | + |
| 21 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 22 | + |
| 23 | +# n-install — introduction |
| 24 | + |
| 25 | +[DO NOT USE YET.] |
| 26 | + |
| 27 | +**Installs [`n`, the Node.js version manager](https://github.com/tj/n)**, on Unix-like platforms, **without needing to install [Node.js](https://nodejs.org/) first**. |
| 28 | +Additionally, installs scripts `n-update` for later on-demand updating of `n`, and `n-uninstall` for uninstalling. |
| 29 | + |
| 30 | +`n` is installed as follows: |
| 31 | + |
| 32 | +* 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/io.js version are placed there. |
| 33 | + * 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. |
| 34 | + * Using a dedicated directory to hold both `n` and the Node.js/io.js versions greatly simplifies later uninstallation. |
| 35 | +* If your shell is **`bash`, `ksh`, or `zsh`, the relevant shell initialization file is updated** to: |
| 36 | + * define environment variable `N_PREFIX` to point to the installation directory |
| 37 | + * append `$N_PREFIX/bin` to the `$PATH` |
| 38 | +* By default, the latest stable Node.js version is installed; you can suppress that or even specify multiple Node.js/io.js versions to install. |
| 39 | + |
| 40 | + |
| 41 | +The simplest case is **installation of `n` with confirmation prompt**, with subsequent **installation of the latest stable Node.js version**: |
| 42 | + |
| 43 | +```shell |
| 44 | +curl -L http://git.io/n-install | bash |
| 45 | +``` |
| 46 | + |
| 47 | +See [more examples](#examples), and [Installing n](#installing-n) for prerequisites and installation options. |
| 48 | + |
| 49 | +# Examples |
| 50 | + |
| 51 | +* With confirmation prompt to confirm installing to `$HOME/n ` and installing the latest stable Node.js version: |
| 52 | + |
| 53 | +```shell |
| 54 | +curl -L http://git.io/n-install | bash |
| 55 | +``` |
| 56 | + |
| 57 | +* Automated installation to default location `$HOME/n` and installation of the latest stable Node.js version: |
| 58 | + |
| 59 | +```shell |
| 60 | +curl -L http://git.io/n-install | bash -s -- -y |
| 61 | +``` |
| 62 | + |
| 63 | +* Automated installation to alternative location `~/util/n`, with subsequent installation of the latest stable Node.js version: |
| 64 | + |
| 65 | +```shell |
| 66 | +curl -L http://git.io/n-install | N_PREFIX=~/util/n bash -s -- -y |
| 67 | +``` |
| 68 | + |
| 69 | +* Automated installation to the default location, with subsequent installation of the specified Node.js and io.js versions: |
| 70 | + |
| 71 | +```shell |
| 72 | +curl -L http://git.io/n-install | N_PREFIX=~/util/n bash -s -- -y stable io:stable 0.10 |
| 73 | +``` |
| 74 | + |
| 75 | +# Installing n |
| 76 | + |
| 77 | +**Supported platforms and prerequisites** |
| 78 | + |
| 79 | +Any Unix-like platform with the following installed: |
| 80 | + |
| 81 | +* [`bash`](http://www.gnu.org/software/bash/) |
| 82 | +* [`curl`](http://curl.haxx.se/) |
| 83 | +* [`git`](http://git-scm.com/) |
| 84 | +* [GNU `make`](http://www.gnu.org/software/make/) |
| 85 | + |
| 86 | +These prerequisites are met by default on OSX and most Linux platforms. |
| 87 | + |
| 88 | +Irrespective of the installation method chosen below, no further steps are required if your default shell is either **Bash, Ksh, or Zsh**. |
| 89 | +For other shells, manual updating of their initialization files is required; detailed instructions are provided during installation. |
| 90 | + |
| 91 | +## Options and background information |
| 92 | + |
| 93 | +<!-- DO NOT EDIT THE FENCED CODE BLOCK and RETAIN THIS COMMENT: The fenced code block below is updated by `make update-readme/release` with CLI usage information. --> |
| 94 | + |
| 95 | +``` |
| 96 | +$ n-install --help |
| 97 | +
|
| 98 | +SYNOPSIS |
| 99 | + n-install [-t] [-y] [version...] |
| 100 | +
|
| 101 | +DESCRIPTION |
| 102 | + Installs n, the Node.js version manager, which bypasses the need to manually |
| 103 | + install a Node.js version first. |
| 104 | +
|
| 105 | + Additionally, installs n-update for updating n, |
| 106 | + and n-uninstall for uninstallation. |
| 107 | +
|
| 108 | + On successful installation of n, the specified Node.js/io.js version(s) |
| 109 | + are installed; by default, this is the latest stable Node.js version; |
| 110 | + To opt out, specify '-' as the only version argument. |
| 111 | + 'stable' installs the latest stable version, available, 'latest' the latest |
| 112 | + available overall; otherwise, specify an explicit version numer, such as |
| 113 | + '0.12' or '0.10.35'. |
| 114 | + To install io.js versions, prefix the version with 'io:'; e.g., 'io:stable'. |
| 115 | + If multiple versions are specified, the first one will be made active. |
| 116 | +
|
| 117 | + The default installation directory is: |
| 118 | +
|
| 119 | + ~/n |
| 120 | + |
| 121 | + which can be overridden by setting environment variable N_PREFIX to an |
| 122 | + absolute path before invocation; either way, however, the installation |
| 123 | + directory must either not exist yet or be empty. |
| 124 | +
|
| 125 | + If your shell is Bash, Ksh, or Zsh, the relevant initialization file will be |
| 126 | + modified so as to: |
| 127 | + - export environment variable $N_PREFIX to point to the installation dir. |
| 128 | + - ensure that the directory containing the n executable, $N_PREFIX/bin, |
| 129 | + is in the $PATH. |
| 130 | + For any other shell you'll have to make these modifications yourself. |
| 131 | +
|
| 132 | + Options: |
| 133 | +
|
| 134 | + -t |
| 135 | + Merely tests if all installation prerequisites are met, which is signaled |
| 136 | + with an exit code of 0. |
| 137 | +
|
| 138 | + -y |
| 139 | + Assumes yes as the reply to all prompts; in other words: runs unattended |
| 140 | + by auto-confirming the prompts. |
| 141 | +
|
| 142 | + For more information, see http://git.io/n-install-repo |
| 143 | +
|
| 144 | +PREREQUISITES |
| 145 | + bash ... to run this script and n itself. |
| 146 | + curl ... to install this script directly from GitHub. |
| 147 | + git ... to clone n's GitHub repository. |
| 148 | + GNU make ... to run n's installation procedure. |
| 149 | + |
| 150 | +EXAMPLES |
| 151 | + # Install n and the latest stable Node.js version, with |
| 152 | + # interactive prompt: |
| 153 | + n-install |
| 154 | + # Only test if installation to the specified location would work. |
| 155 | + N_PREFIX=~/util/n n-install -t |
| 156 | + # Automated installation of n, without installing the latest |
| 157 | + # stable Node.js version. |
| 158 | + n-install -y - |
| 159 | + # Automated installation of n, followed by automated installation |
| 160 | + # of the latest stable and unstable Node.js versions, as well |
| 161 | + # as the latest 0.8.x version. |
| 162 | + n-install -y stable latest 0.8 |
| 163 | +``` |
| 164 | + |
| 165 | +# Updating n |
| 166 | + |
| 167 | +Run `n-update` on demand to update `n` itself; `n-update -y` skips the confirmation prompt. |
| 168 | + |
| 169 | +## Manual updating |
| 170 | + |
| 171 | +If, for some reason, `n-update` doesn't work or isn't available, run the following to update `n`: |
| 172 | + |
| 173 | +* `cd "$N_PREFIX/n/.repo" && git pull && PREFIX="$N_PREFIX" make install && cd -` |
| 174 | + |
| 175 | +# Uninstalling n |
| 176 | + |
| 177 | +Run `n-uninstall`; `n-uninstall -y` skips the confirmation prompt. |
| 178 | + |
| 179 | +## Manual uninstallation |
| 180 | + |
| 181 | +If, for some reason, `n-uninstall` doesn't work, do the following to uninstall `n`: |
| 182 | + |
| 183 | +* Remove the `N_PREFIX` environment-variable definition and associated `PATH` modification from your shell's initialization file. |
| 184 | + |
| 185 | +* Remove the directory that `N_PREFIX` points to: |
| 186 | + * Be sure that that directory contains no content unrelated to `n` that you may want to preserve. |
| 187 | + * If `$N_PREFIX` is not defined, look in the default installation location, `~/n`. |
| 188 | + |
| 189 | + |
| 190 | +<!-- DO NOT EDIT THE NEXT CHAPTER and RETAIN THIS COMMENT: The next chapter is updated by `make update-readme/release` with the contents of 'LICENSE.md'. ALSO, LEAVE AT LEAST 1 BLANK LINE AFTER THIS COMMENT. --> |
| 191 | + |
| 192 | +# License |
| 193 | + |
| 194 | +Copyright (c) 2015 Michael Klement <[email protected]> ( http://same2u.net), released under the [MIT license ](https://spdx.org/licenses/MIT#licenseText). |
| 195 | + |
| 196 | +## Acknowledgements |
| 197 | + |
| 198 | +This project gratefully depends on the following open-source components, according to the terms of their respective licenses. |
| 199 | + |
| 200 | +[npm](https://www.npmjs.com/) dependencies below have optional suffixes denoting the type of dependency; the *absence* of a suffix denotes a required *run-time* dependency: `(D)` denotes a *development-time-only* dependency, `(O)` an *optional* dependency, and `(P)` a *peer* dependency. |
| 201 | + |
| 202 | +<!-- DO NOT EDIT THE NEXT CHAPTER and RETAIN THIS COMMENT: The next chapter is updated by `make update-readme/release` with the dependencies from 'package.json'. ALSO, LEAVE AT LEAST 1 BLANK LINE AFTER THIS COMMENT. --> |
| 203 | + |
| 204 | +## npm dependencies |
| 205 | + |
| 206 | +* [doctoc (D)](https://github.com/thlorenz/doctoc) |
| 207 | +* [json (D)](https://github.com/trentm/json) |
| 208 | +* [replace (D)](https://github.com/harthur/replace) |
| 209 | +* [semver (D)](https://github.com/npm/node-semver#readme) |
| 210 | +* [tap (D)](https://github.com/isaacs/node-tap) |
| 211 | +* [urchin (D)](https://github.com/tlevine/urchin) |
| 212 | + |
| 213 | +<!-- DO NOT EDIT THE NEXT CHAPTER and RETAIN THIS COMMENT: The next chapter is updated by `make update-readme/release` with the contents of 'CHANGELOG.md'. ALSO, LEAVE AT LEAST 1 BLANK LINE AFTER THIS COMMENT. --> |
| 214 | + |
| 215 | +# Changelog |
| 216 | + |
| 217 | +Versioning complies with [semantic versioning (semver)](http://semver.org/). |
| 218 | + |
| 219 | +<!-- NOTE: An entry template for a new version is automatically added each time `make version` is called. Fill in changes afterwards. --> |
| 220 | + |
| 221 | +* **v0.0.1** (2015-06-16): |
| 222 | + * Preparing for true initial release (0.1.0). |
0 commit comments