Changes to n

John Gee
John Gee
6 months ago
10.1.0
package-lock.json
Changed around line 1
- "version": "10.0.1-0",
+ "version": "10.1.0",
package.json
Changed around line 1
- "version": "10.0.1-0",
+ "version": "10.1.0",
John Gee
John Gee
6 months ago
Update CHANGELOG for 10.1.0
CHANGELOG.md
Changed around line 9: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [10.1.0] (2024-10-20)
+ ## [10.1.0] (2024-11-09)
- - `--cleanup` removes cached version after install ([#818])
+ - `--cleanup` option to delete cached version after install for a one-shot install ([#818])
+ - `download` command to download Node.js version into cache ([#821])
- document using `--download` with run/exec/which in README
+ - support trailing comments in `.nvmrc` file ([#820])
+ - mask password in download URL when displayed ([#815])
Changed around line 531: Only minor functional changes, but technically could break scripts relying on sp
+ [#815]: https://github.com/tj/n/pull/815
+ [#820]: https://github.com/tj/n/pull/820
+ [#821]: https://github.com/tj/n/pull/821
John Gee
John Gee
6 months ago
Add unofficial builds as example mirror (#823)
README.md
Changed around line 20: Node.js version management: no subshells, no profile setup, no convoluted API, j
- [Using Downloaded Node.js Versions Without Reinstalling](#using-downloaded-nodejs-versions-without-reinstalling)
- [Preserving npm](#preserving-npm)
- [Miscellaneous](#miscellaneous)
- - [Custom Source](#custom-source)
+ - [Custom Mirror](#custom-mirror)
- [Custom Architecture](#custom-architecture)
- [Optional Environment Variables](#optional-environment-variables)
- [How It Works](#how-it-works)
Changed around line 254: Display diagnostics to help resolve problems:
- ## Custom Source
+ ## Custom Mirror
- The most common example is from users in China who can define:
+
+ One example is for users in China who can define:
+ Another example is the Node.js [unofficial-builds project](https://github.com/nodejs/unofficial-builds/) which has downloads for some platforms not made available officially, such as armv6l (Raspberry Pi) and 32-bit x86.
+
+ export N_NODE_MIRROR=https://unofficial-builds.nodejs.org/download/release
+
+ You may need to specify the architecture explicitly if not autodetected by `n`, such as using `musl` `libc` on Alpine:
+
+ export N_NODE_MIRROR=https://unofficial-builds.nodejs.org/download/release
+ apk add bash curl libstdc++
+ n --arch x64-musl install lts
+
John Gee
John Gee
6 months ago
Add manual install instructions and remove probably rarely used make instruction (#822)
README.md
Changed around line 64: If `npm` is not yet available, one way to bootstrap an install is to download an
- Alternatively, you can clone this repo and
+ If you don't need support for updates to `n` itself you can just save the download:
- make install
-
- which defaults to `/usr/local/bin/n`. To install `n` in a custom location such as `$CUSTOM_LOCATION/bin/n`, run `PREFIX=$CUSTOM_LOCATION make install`.
+ curl -fsSL -o /usr/local/bin/n https://raw.githubusercontent.com/tj/n/master/bin/n
+ chmod 0755 /usr/local/bin/n
+ n install lts
John Gee
John Gee
6 months ago
Add download command (#821)
README.md
Changed around line 234: List downloaded versions in cache:
+ Download version into cache:
+
+ n download 22
+
bin/n
Changed around line 390: Commands:
+ n download Download Node.js into cache
Changed around line 795: install() {
+ else
+ log downloaded "${g_mirror_folder_name}/${version} already in cache"
Changed around line 805: install() {
- log installing "${g_mirror_folder_name}-v$version"
+ if [[ "$DOWNLOAD" == "false" ]]; then
+ log installing "${g_mirror_folder_name}-v$version"
+ else
+ log download "${g_mirror_folder_name}-v$version"
+ fi
Changed around line 1740: else
+ download) shift; DOWNLOAD="true"; install "$1"; exit ;;
test/tests/install-options.bats
Changed around line 17: function teardown() {
+ # deprecated use of --download, replaced by download command
- # Remember, we installed a dummy node so do have a bin/node
+ [ ! -f "${N_PREFIX}/bin/node" ]
+ [ ! -f "${N_PREFIX}/bin/npm" ]
+ [ ! -d "${N_PREFIX}/include" ]
+ [ ! -d "${N_PREFIX}/lib" ]
+ [ ! -d "${N_PREFIX}/shared" ]
+ }
+
+
+ @test "n download 4.9.1" {
+ # not an option, but keep with --download so stays in sync
+ n download 4.9.1
+ [ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
+ [ ! -f "${N_PREFIX}/bin/node" ]
Changed around line 48: function teardown() {
+ @test "n --cleanup 4.9.1" {
+ n install --cleanup 4.9.1
+ output="$(node --version)"
+ assert_equal "${output}" "v4.9.1"
+ [ ! -d "${N_PREFIX}/n/versions/node/4.9.1" ]
+ }
+
+
test/tests/offline.bats
Changed around line 8: function setup_file() {
- n --download 16.19.0
+ n download 16.19.0
test/tests/run-which.bats
Changed around line 9: function setup_file() {
- n --download 4.9.1
- n --download lts
+ n download 4.9.1
+ n download lts
John Gee
John Gee
6 months ago
Add support for trailing comment in .nvmrc (#820)
bin/n
Changed around line 1147: function get_nvmrc_version() {
+ # remove trailing comment, after #
+ version="$(echo "${version}" | sed 's/[[:space:]]*#.*//')"
test/tests/version-resolve-auto-nvmrc.bats
Changed around line 68: function setup() {
+
+ @test "auto .nvmrc, trailing comment" {
+ local TARGET_VERSION="8.10.0"
+ cd "${MY_DIR}"
+ printf "${TARGET_VERSION} # comment" > .nvmrc
+ output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
+ assert_equal "${output}" "${TARGET_VERSION}"
+ }
John Gee
John Gee
6 months ago
Minor reword
README.md
Changed around line 242: Remove the cache version after installing using `--cleanup`. This is particularl
- Normally `n run`, `n exec`, and `n which` will fail if the target version is not already in the cache. You can add `--download` to use the cache if available or download first if required:
+ Normally `n run`, `n exec`, and `n which` will fail if the target version is not already in the cache. You can add `--download` to use the cache if available or download if required:
John Gee
John Gee
6 months ago
Add more codenames, out to 2026
bin/n
Changed around line 262: function update_arch_settings_for_version() {
- [[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od)$ ]]
+ [[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od|[Kk]rypton|[Ll]ithium)$ ]]
test/tests/install-options.bats
Changed around line 19: function teardown() {
- # Remember, we installed a dumy node so do have a bin/node
+ # Remember, we installed a dummy node so do have a bin/node
John Gee
John Gee
6 months ago
Documentation updates
CHANGELOG.md
Changed around line 14: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `--cleanup` removes cached version after install ([#818])
- - mention of `--download` in README
+ - document using `--download` with run/exec/which in README
README.md
Changed around line 93: As a result, both `n` itself and all Node.js versions it manages are hosted insi
+
Changed around line 242: Remove the cache version after installing using `--cleanup`. This is particularl
- The `--download` option can be used in two ways, to download a version into cache but not make active:
-
- n --download lts
-
- or to download a possibly missing version for `n run`, `n exec`, and `n which`:
+ Normally `n run`, `n exec`, and `n which` will fail if the target version is not already in the cache. You can add `--download` to use the cache if available or download first if required:
Changed around line 287: To change the location to say `$HOME/.n`, add lines like the following to your s
- If you want to store the downloads under a different location, use `N_CACHE_PREFIX`. This does *not* affect the currently active
- node version.
+ If you want to store the downloads under a different location, use `N_CACHE_PREFIX`. This does _not_ affect where the active
+ node version is installed.
bin/n
Changed around line 397: Options:
- h, --help Display help information
- p, --preserve Preserve npm and npx during install of Node.js
- q, --quiet Disable curl output. Disable log messages processing "auto" and "engine" labels.
- -d, --download Download if necessary, and don't make active
+ -d, --download Download if necessary. Used with run/exec/which.
- -cleanup Remove cached version after install
- a, --arch Override system architecture
- -offline Resolve target version against cached downloads instead of internet lookup
John Gee
John Gee
6 months ago
Merge branch 'develop' of github.com:tj/n into develop