You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[`n` – Interactively Manage Your Node.js Versions](#n-%E2%80%93-interactively-manage-your-nodejs-versions)
15
15
-[Installation](#installation)
@@ -27,20 +27,20 @@ Node.js version management: no subshells, no profile setup, no convoluted API, j
27
27
28
28
Since you probably already have `node`, the easiest way to install `n` is through `npm`:
29
29
30
-
$ npm install -g n
30
+
npm install -g n
31
31
32
32
Alternatively, you can clone this repo and
33
33
34
-
$ make install
34
+
make install
35
35
36
36
to install `n` to `bin/n` of the directory specified in the environment variable `$PREFIX`, which defaults to `/usr/local` (note that you will likely need to use `sudo`). To install `n` in a custom location (such as `$CUSTOM_LOCATION/bin/n`), run `PREFIX=$CUSTOM_LOCATION make install`.
37
37
38
38
Once installed, `n` installs `node` versions to subdirectory `n/versions` of the directory specified in environment variable `N_PREFIX`, which defaults to `/usr/local`; the _active_`node` version is installed directly in `N_PREFIX`.
39
-
To change the default to, say, `$HOME`, prefix later calls to `n` with `N_PREFIX=$HOME` or add `export N_PREFIX=$HOME` to your shell initialization file.
39
+
To change the default to, say, `$HOME`, prefix later calls to `n` with `N_PREFIX=$HOME` or add `export N_PREFIX=$HOME` to your shell initialization file.
40
40
41
41
To avoid requiring `sudo` for `n` and `npm` global installs, it is recommended you either install to your home directory using `N_PREFIX`, or take ownership of the system directories:
42
42
43
-
```
43
+
```bash
44
44
# make cache folder (if missing) and take ownership
45
45
sudo mkdir -p /usr/local/n
46
46
sudo chown -R $(whoami) /usr/local/n
@@ -60,17 +60,16 @@ On Linux and macOS, [n-install](https://github.com/mklement0/n-install) allows i
60
60
61
61
n-install sets both `PREFIX` and `N_PREFIX` to `$HOME/n`, installs `n` to `$HOME/n/bin`, modifies the initialization files of supported shells to export `N_PREFIX` and add `$HOME/n/bin` to the `PATH`, and installs the latest stable `node` version.
62
62
63
-
64
63
As a result, both `n` itself and all `node` versions it manages are hosted inside a single, optionally configurable directory, which you can later remove with the included `n-uninstall` script. `n-update` updates `n` itself to the latest version. See the [n-install repo](https://github.com/mklement0/n-install) for more details.
65
64
66
65
## Installing/Activating Node Versions
67
66
68
67
Simply execute `n <version>` to install a version of `node`. If `<version>` has already been installed (via `n`), `n` will activate that version.
69
68
A leading v is optional, and a partial version number installs the newest matching version.
70
69
71
-
$ n 4.9.1
72
-
$ n 10
73
-
$ n v8.11.3
70
+
n 4.9.1
71
+
n 10
72
+
n v8.11.3
74
73
75
74
Execute `n` on its own to view your currently installed versions. Use the up and down arrow keys to navigate and press enter to select. Use `q` or ^C (control + C) to exit the selection screen.
76
75
If you like vim key bindings during the selection of node versions, you can use `j` and `k` to navigate up or down without using arrows.
@@ -83,27 +82,21 @@ If you like vim key bindings during the selection of node versions, you can use
83
82
84
83
Use or install the latest official release:
85
84
86
-
$ n latest
85
+
n latest
87
86
88
87
Use or install the latest LTS official release:
89
88
90
-
$ n lts
89
+
n lts
91
90
92
91
## Removing Versions
93
92
94
93
Remove some versions:
95
94
96
-
$ n rm 0.9.4 v0.10.0
97
-
98
-
Alternatively, you can use `-` in lieu of `rm`:
99
-
100
-
$ n - 0.9.4
95
+
n rm 0.9.4 v0.10.0
101
96
102
97
Removing all versions except the current version:
103
98
104
-
```bash
105
-
$ n prune
106
-
```
99
+
n prune
107
100
108
101
## Binary Usage
109
102
@@ -115,11 +108,11 @@ them directly by asking `n` for the binary path:
115
108
116
109
Or by using a specific version through `n`'s `use` sub-command:
117
110
118
-
$ n use 0.9.4 some.js
111
+
n use 0.9.4 some.js
119
112
120
113
Flags also work here:
121
114
122
-
$ n as 0.9.4 --debug some.js
115
+
n as 0.9.4 --debug some.js
123
116
124
117
## Usage
125
118
@@ -171,26 +164,26 @@ For example, to grab the latest io.js version:
171
164
172
165
Required Variables:
173
166
174
-
*`PROJECT_NAME`: The name the project will be stored under
175
-
*`PROJECT_URL`: The location to download the project from. Note, this must follow the same format as the Node.js repos
167
+
-`PROJECT_NAME`: The name the project will be stored under
168
+
-`PROJECT_URL`: The location to download the project from. Note, this must follow the same format as the Node.js repos
176
169
177
170
Optional Variables:
178
171
179
-
*`HTTP_USER`: The username if the `PROJECT_URL` is protected by basic authentication
180
-
*`HTTP_PASSWORD`: The password if the `PROJECT_URL` is protected by basic authentication
181
-
*`PROJECT_VERSION_CHECK`: Many custom projects keep the same version number as the Node.js release they are based on, and maintain their own separate version in process. This allows you to define a JavaScript variable that will be used to check for the version of the process, for example: `process.versions.node`
172
+
-`HTTP_USER`: The username if the `PROJECT_URL` is protected by basic authentication
173
+
-`HTTP_PASSWORD`: The password if the `PROJECT_URL` is protected by basic authentication
174
+
-`PROJECT_VERSION_CHECK`: Many custom projects keep the same version number as the Node.js release they are based on, and maintain their own separate version in process. This allows you to define a JavaScript variable that will be used to check for the version of the process, for example: `process.versions.node`
182
175
183
176
## Custom architecture
184
177
185
178
By default `n` picks the binaries matching your system architecture, e.g. `n` will download 64 bit binaries for a 64 bit system. You can override this by using the `-a` or `--arch` option.
186
179
187
180
Download and use latest 32 bit version of `node`:
188
181
189
-
$ n --arch x86 latest
182
+
n --arch x86 latest
190
183
191
184
Download and use 64 bit LTS version of `node` for older Mac Intel Core 2 Duo systems (x86 image is no longer available but x64 runs fine):
0 commit comments