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
John Gee
John Gee
6 months ago
Prepare for release
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)
+
+ ### Added
+
+ - `--cleanup` removes cached version after install ([#818])
+ - mention of `--download` in README
+
+ ### Changed
+
+ - removed stale code ([#817])
+
Changed around line 528: Only minor functional changes, but technically could break scripts relying on sp
+ [#817]: https://github.com/tj/n/pull/817
+ [#818]: https://github.com/tj/n/pull/818
+ [10.1.0]: https://github.com/tj/n/compare/v10.0.0...v10.1.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v10.0.1-0"
+ VERSION="v10.1.0"
John Gee
John Gee
6 months ago
Remove stale while loop (#817)
bin/n
Changed around line 1717: if test $# -eq 0; then
- while test $# -ne 0; do
- case "$1" in
- bin|which) display_bin_path_for_version "$2"; exit ;;
- run|as|use) shift; run_with_version "$@"; exit ;;
- exec) shift; exec_with_version "$@"; exit ;;
- doctor) show_diagnostics; exit ;;
- rm|-) shift; remove_versions "$@"; exit ;;
- prune) prune_cache; exit ;;
- latest) install latest; exit ;;
- stable) install stable; exit ;;
- lts) install lts; exit ;;
- ls|list) display_versions_paths; exit ;;
- lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
- uninstall) uninstall_installed; exit ;;
- i|install) shift; install "$1"; exit ;;
- N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
- *) install "$1"; exit ;;
- esac
- shift
- done
+ case "$1" in
+ bin|which) display_bin_path_for_version "$2"; exit ;;
+ run|as|use) shift; run_with_version "$@"; exit ;;
+ exec) shift; exec_with_version "$@"; exit ;;
+ doctor) show_diagnostics; exit ;;
+ rm|-) shift; remove_versions "$@"; exit ;;
+ prune) prune_cache; exit ;;
+ latest) install latest; exit ;;
+ stable) install stable; exit ;;
+ lts) install lts; exit ;;
+ ls|list) display_versions_paths; exit ;;
+ lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
+ uninstall) uninstall_installed; exit ;;
+ i|install) shift; install "$1"; exit ;;
+ N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
+ *) install "$1"; exit ;;
+ esac
John Gee
John Gee
6 months ago
Add --cleanup (#818)
README.md
Changed around line 60: To take ownership of the system directories (option 1):
- curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts
+ curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install lts
Changed around line 237: Use `n` to access cached versions (already downloaded) without internet availabl
+ Remove the cache version after installing using `--cleanup`. This is particularly useful for a one-shot install, like in a docker container.
+
+ curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install --cleanup lts
+
+ 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`:
+
+ n --download run 18.3 my-script.js
+
bin/n
Changed around line 133: g_active_node=
+ CLEANUP=false # remove cached download after install
Changed around line 398: Options:
- 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
+ --cleanup Remove cached version after install
- a, --arch Override system architecture
- -offline Resolve target version against cached downloads instead of internet lookup
- -all ls-remote displays all matches instead of last 20
Changed around line 759: activate() {
+
+ if [[ "$CLEANUP" == "true" ]]; then
+ log "cleanup" "removing cached $version"
+ remove_versions "$version"
+ fi
+
Changed around line 1680: while [[ $# -ne 0 ]]; do
- h|--help|help) display_help; exit ;;
- q|--quiet) set_quiet ;;
- d|--download) DOWNLOAD="true" ;;
+ --cleanup) CLEANUP="true" ;;
- -offline) OFFLINE="true" ;;
- -insecure) set_insecure ;;
- p|--preserve) N_PRESERVE_NPM="true" N_PRESERVE_COREPACK="true" ;;
jinxiao
jinxiao
7 months ago
mask download url when there is a password (#815)
bin/n
Changed around line 197: display_major_version() {
+ display_masked_url() {
+ echo "$1" | sed -r 's/(https?:\/\/[^:]+):([^@]+)@/\1:****@/'
+ }
+
Changed around line 797: install() {
- is_ok "${url}" || abort "download preflight failed for '$version' (${url})"
+ is_ok "${url}" || abort "download preflight failed for '$version' ($(display_masked_url "${url}"))"
Changed around line 805: install() {
- log fetch "$url"
+ log fetch "$(display_masked_url "${url}")"
Changed around line 1245: display_remote_index() {
- abort "failed to download version index (${index_url})"
+ abort "failed to download version index ($(display_masked_url "${index_url}"))"
Changed around line 1498: function show_diagnostics() {
- echo "node mirror: ${N_NODE_MIRROR}"
- echo "node downloads mirror: ${N_NODE_DOWNLOAD_MIRROR}"
+ echo "node mirror: $(display_masked_url "${N_NODE_MIRROR}")"
+ echo "node downloads mirror: $(display_masked_url "${N_NODE_DOWNLOAD_MIRROR}")"
John Gee
John Gee
8 months ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v10.0.0"
+ VERSION="v10.0.1-0"
package-lock.json
Changed around line 1
- "version": "10.0.0",
+ "version": "10.0.1-0",
package.json
Changed around line 1
- "version": "10.0.0",
+ "version": "10.0.1-0",
John Gee
John Gee
8 months ago
10.0.0
package-lock.json
Changed around line 1
- "version": "9.2.4-0",
+ "version": "10.0.0",
package.json
Changed around line 1
- "version": "9.2.4-0",
+ "version": "10.0.0",
John Gee
John Gee
8 months ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [10.0.0] (2024-09-06)
+
+ The major version bump is due to using `jq` in preference to `node` for reading `package.json`.
- if `jq` is available, use `jq` for reading `engines` from `package.json` instead of using `node` ([#810])
+ - avoid a network lookup if auto or engine find a fully specified numeric version. ([#813])
Changed around line 514: Only minor functional changes, but technically could break scripts relying on sp
+ [#813]: https://github.com/tj/n/pull/813
+ [10.0.0]: https://github.com/tj/n/compare/v9.2.3...v10.0.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.4-0"
+ VERSION="v10.0.0"
John Gee
John Gee
8 months ago
Fast track exact auto (#813)
bin/n
Changed around line 1205: function get_auto_version() {
+
+ # Transform some labels before processing further to allow fast-track for exact numeric versions.
+ if [[ "${version}" = "auto" ]]; then
+ get_auto_version || return 2
+ version="${g_target_node}"
+ elif [[ "${version}" = "engine" ]]; then
+ get_engine_version || return 2
+ version="${g_target_node}"
+ fi
+
Changed around line 1269: function display_local_versions() {
- # suppress stdout logging so lsr layout same as usual for scripting
- # suppress stdout logging so lsr layout same as usual for scripting
Changed around line 1318: function display_remote_versions() {
- # suppress stdout logging so lsr layout same as usual for scripting
- # suppress stdout logging so lsr layout same as usual for scripting
test/bin/run-all-tests
Changed around line 7: services=( fedora-curl ubuntu-wget )
- docker-compose run --rm "${service}" "bats" "/mnt/test/tests"
+ docker compose run --rm "${service}" "bats" "/mnt/test/tests"
test/docker-compose.yml
Changed around line 1
- version: '2'
test/tests.md
Changed around line 20: Run all the tests on a single system:
- docker-compose run ubuntu-curl bats /mnt/test/tests
+ docker compose run ubuntu-curl bats /mnt/test/tests
- docker-compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
+ docker compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
- Using `docker-compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.
+ Using `docker compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.
Changed around line 38: The containers each have:
- Using `docker-compose` to run the container adds:
+ Using `docker compose` to run the container adds:
Changed around line 48: Using `docker-compose` to run the container adds:
- docker-compose run ubuntu-curl
+ docker compose run ubuntu-curl
John Gee
John Gee
8 months ago
Add use of jq to README and CHANGELOG
CHANGELOG.md
Changed around line 9: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ### Changed
+
+ - if `jq` is available, use `jq` for reading `engines` from `package.json` instead of using `node` ([#810])
+
Changed around line 510: Only minor functional changes, but technically could break scripts relying on sp
+ [#810]: https://github.com/tj/n/pull/810
README.md
Changed around line 143: There is an `auto` label to read the target version from a file in the current d
- `.nvmrc`: version on single line. Used by `nvm`.
- if no version file found, look for `engine` as below.
- The `engine` label looks for a `package.json` file and reads the `engines` field to determine compatible Node.js. Requires an installed version of `node`, and uses `npx semver` to resolve complex ranges.
+ The `engine` label looks for a `package.json` file and reads the `engines` field to determine compatible Node.js. Requires an installed version of `jq` or `node`, and uses `npx semver` to resolve complex ranges.
John Gee
John Gee
8 months ago
Simplify doctor info for jq, in line with other diagnostics
bin/n
Changed around line 1480: function show_diagnostics() {
- if command -v jq &> /dev/null; then
- jq --version
- else
- echo "jq not found, can be used to get package.json values faster than node"
- fi
+ command -v jq && jq --version
John Gee
John Gee
8 months ago
Remove redundant checks for commands
bin/n
Changed around line 1456: function show_diagnostics() {
- command -v node && node --version
+ node --version
Changed around line 1465: function show_diagnostics() {
- command -v tar && tar --version
+ tar --version
- command -v curl && curl --version
+ curl --version
- command -v wget && wget --version
+ wget --version
- command -v jq && jq --version
+ jq --version
Eli Barzilay
Eli Barzilay
8 months ago
If `jq` is installed, use it to get values from package.json (#810) `jq` is a popular choice for being installed, especially on CI machines, and using it to read engines from package.json is faster than running node.
bin/n
Changed around line 1084: function get_package_engine_version() {
- command -v node &> /dev/null || abort "an active version of node is required to read 'engines' from package.json"
- range="$(node -e "package = require('${filepath}'); if (package && package.engines && package.engines.node) console.log(package.engines.node)")"
+ if command -v jq &> /dev/null; then
+ range="$(jq -r '.engines.node // ""' < "${filepath}")"
+ elif command -v node &> /dev/null; then
+ range="$(node -e "package = require('${filepath}'); if (package && package.engines && package.engines.node) console.log(package.engines.node)")"
+ else
+ abort "either jq or an active version of node is required to read 'engines' from package.json"
+ fi
Changed around line 1479: function show_diagnostics() {
+ printf "\njq\n"
+ if command -v jq &> /dev/null; then
+ command -v jq && jq --version
+ else
+ echo "jq not found, can be used to get package.json values faster than node"
+ fi
+
John Gee
John Gee
11 months ago
Merge branch 'master' into develop
Helber Belmiro
Helber Belmiro
11 months ago
Fixed broken link (#803)
README.md
Changed around line 90: As a result, both `n` itself and all Node.js versions it manages are hosted insi
- Changing from a previous Node.js installed to a different location may involve a few extra steps. See docs for [changing node location]((./docs/changing-node-location.md)) for a walk-through example of switching from using Homebrew to using `n` to manage Node.js.
+ Changing from a previous Node.js installed to a different location may involve a few extra steps. See docs for [changing node location](./docs/changing-node-location.md) for a walk-through example of switching from using Homebrew to using `n` to manage Node.js.
John Gee
John Gee
1 year ago
Docs for switching node directory (#802)
README.md
Changed around line 13: Node.js version management: no subshells, no profile setup, no convoluted API, j
- [Supported Platforms](#supported-platforms)
- [Installation](#installation)
- [Third Party Installers](#third-party-installers)
+ - [Replacing a previous node install](#replacing-a-previous-node-install)
- [Installing Node.js Versions](#installing-nodejs-versions)
- [Specifying Node.js Versions](#specifying-nodejs-versions)
- [Removing Versions](#removing-versions)
Changed around line 88: n-install sets both `PREFIX` and `N_PREFIX` to `$HOME/n`, installs `n` to `$HOME
+ ### Replacing a previous node install
+
+ Changing from a previous Node.js installed to a different location may involve a few extra steps. See docs for [changing node location]((./docs/changing-node-location.md)) for a walk-through example of switching from using Homebrew to using `n` to manage Node.js.
+
+ You have a problem with multiple versions if after installing node you see the "installed" and "active" locations are different:
+ ```console
+ % n lts
+ copying : node/20.12.2
+ installed : v20.12.2 to /usr/local/bin/node
+ active : v21.7.3 at /opt/homebrew/bin/node
+ ```
+
docs/changing-node-location.md
Changed around line 1
+ # Switching To `n` Managed Node.js
+
+ If you already have Node.js installed to a different root than `n` uses, you can easily end up with multiple copies of node (and npm, and npx, and globally installed packages!). Some common situations are you already had Node.js installed using your Linux package manager, or using another node version manager, or using say Homebrew. The two main ways you might resolve this are:
+
+ - uninstall from the old directory and reinstall to the new directory
+ - put the `bin` directory that `n` uses early in the `PATH` environment variable, so the `n` installed node is found first
+
+ The simplest setup to understand is the first one. Just have one version of `node` installed.
+
+ Let's walk-through the process of switching over from using Homebrew as an example. Let's start off with Node.js installed, `npm` updated, and an example global npm package. The key point is there are two install prefixes involved:
+
+ - old: `/opt/homebrew`
+ - new: `/usr/local`
+
+ ```console
+ % brew install node
+ % npm install --global npm@latest
+ % npm install --global @shadowspawn/forest-arborist
+ % brew list node
+ /opt/homebrew/Cellar/node/21.7.3/bin/node
+ /opt/homebrew/Cellar/node/21.7.3/bin/npm
+ /opt/homebrew/Cellar/node/21.7.3/bin/npx
+ /opt/homebrew/Cellar/node/21.7.3/etc/bash_completion.d/npm
+ /opt/homebrew/Cellar/node/21.7.3/include/node/ (107 files)
+ /opt/homebrew/Cellar/node/21.7.3/libexec/bin/ (2 files)
+ /opt/homebrew/Cellar/node/21.7.3/libexec/lib/ (2012 files)
+ /opt/homebrew/Cellar/node/21.7.3/share/doc/ (2 files)
+ /opt/homebrew/Cellar/node/21.7.3/share/man/man1/node.1
+ % command -v node
+ /opt/homebrew/bin/node
+ % command -v npm
+ /opt/homebrew/bin/npm
+ % npm prefix --global
+ /opt/homebrew
+ ```
+
+ Before we start transferring, list the global npm packages in the "old" location. We will refer back to this list.
+
+ ```console
+ % npm list --global
+ /opt/homebrew/lib
+ ├── @shadowspawn/forest-arborist@12.0.0
+ └── npm@10.5.0
+ ```
+
+ We could clean out the old location first, but let's install `n` and another copy of node and see what that looks like. We end up with two versions of node, and the active one is still the Homebrew managed version.
+
+ ```console
+ % brew install n
+ % n lts
+ installing : node-v20.12.2
+ mkdir : /usr/local/n/versions/node/20.12.2
+ fetch : https://nodejs.org/dist/v20.12.2/node-v20.12.2-darwin-arm64.tar.xz
+ copying : node/20.12.2
+ installed : v20.12.2 to /usr/local/bin/node
+ active : v21.7.3 at /opt/homebrew/bin/node
+ % command -v node
+ /opt/homebrew/bin/node
+ % which -a node
+ /opt/homebrew/bin/node
+ /usr/local/bin/node
+ % command -v npm
+ /opt/homebrew/bin/npm
+ % command -v npx
+ /opt/homebrew/bin/npx
+ % n doctor
+ <...>
+
+ CHECKS
+
+ Checking n install destination is in PATH...
+ good
+
+ Checking n install destination priority in PATH...
+ ⚠️ There is a version of node installed which will be found in PATH before the n installed version.
+
+ Checking npm install destination...
+ ⚠️ There is an active version of npm shadowing the version installed by n. Check order of entries in PATH.
+ installed : /usr/local/bin/npm
+ active : /opt/homebrew/bin/npm
+
+ <...>
+ ```
+
+ Now let's switch over. Delete everything from the old location. Delete all the global npm packages _except_ npm itself, then delete npm, then delete node.
+
+ ```console
+ npm uninstall --global @shadowspawn/forest-arborist
+
+ npm uninstall --global npm
+
+ brew uninstall node
+ ```
+
+ Check the active binaries are now the ones installed by `n`:
+ ```console
+ % command -v node
+ /usr/local/bin/node
+ % command -v npm
+ /usr/local/bin/npm
+ % command -v npx
+ /usr/local/bin/npx
+ ```
+
+ And lastly, reinstall the global npm packages you started with:
+ ```
+ % npm prefix --global
+ /usr/local
+ % npm install --global npm@latest
+ % npm install --global @shadowspawn/forest-arborist
+ % npm list -g
+ /usr/local/lib
+ ├── @shadowspawn/forest-arborist@12.0.0
+ └── npm@10.5.0
+ ```
John Gee
John Gee
1 year ago
Docs for switching node directory (#802)
README.md
Changed around line 13: Node.js version management: no subshells, no profile setup, no convoluted API, j
- [Supported Platforms](#supported-platforms)
- [Installation](#installation)
- [Third Party Installers](#third-party-installers)
+ - [Replacing a previous node install](#replacing-a-previous-node-install)
- [Installing Node.js Versions](#installing-nodejs-versions)
- [Specifying Node.js Versions](#specifying-nodejs-versions)
- [Removing Versions](#removing-versions)
Changed around line 88: n-install sets both `PREFIX` and `N_PREFIX` to `$HOME/n`, installs `n` to `$HOME
+ ### Replacing a previous node install
+
+ Changing from a previous Node.js installed to a different location may involve a few extra steps. See docs for [changing node location]((./docs/changing-node-location.md)) for a walk-through example of switching from using Homebrew to using `n` to manage Node.js.
+
+ You have a problem with multiple versions if after installing node you see the "installed" and "active" locations are different:
+ ```console
+ % n lts
+ copying : node/20.12.2
+ installed : v20.12.2 to /usr/local/bin/node
+ active : v21.7.3 at /opt/homebrew/bin/node
+ ```
+
docs/changing-node-location.md
Changed around line 1
+ # Switching To `n` Managed Node.js
+
+ If you already have Node.js installed to a different root than `n` uses, you can easily end up with multiple copies of node (and npm, and npx, and globally installed packages!). Some common situations are you already had Node.js installed using your Linux package manager, or using another node version manager, or using say Homebrew. The two main ways you might resolve this are:
+
+ - uninstall from the old directory and reinstall to the new directory
+ - put the `bin` directory that `n` uses early in the `PATH` environment variable, so the `n` installed node is found first
+
+ The simplest setup to understand is the first one. Just have one version of `node` installed.
+
+ Let's walk-through the process of switching over from using Homebrew as an example. Let's start off with Node.js installed, `npm` updated, and an example global npm package. The key point is there are two install prefixes involved:
+
+ - old: `/opt/homebrew`
+ - new: `/usr/local`
+
+ ```console
+ % brew install node
+ % npm install --global npm@latest
+ % npm install --global @shadowspawn/forest-arborist
+ % brew list node
+ /opt/homebrew/Cellar/node/21.7.3/bin/node
+ /opt/homebrew/Cellar/node/21.7.3/bin/npm
+ /opt/homebrew/Cellar/node/21.7.3/bin/npx
+ /opt/homebrew/Cellar/node/21.7.3/etc/bash_completion.d/npm
+ /opt/homebrew/Cellar/node/21.7.3/include/node/ (107 files)
+ /opt/homebrew/Cellar/node/21.7.3/libexec/bin/ (2 files)
+ /opt/homebrew/Cellar/node/21.7.3/libexec/lib/ (2012 files)
+ /opt/homebrew/Cellar/node/21.7.3/share/doc/ (2 files)
+ /opt/homebrew/Cellar/node/21.7.3/share/man/man1/node.1
+ % command -v node
+ /opt/homebrew/bin/node
+ % command -v npm
+ /opt/homebrew/bin/npm
+ % npm prefix --global
+ /opt/homebrew
+ ```
+
+ Before we start transferring, list the global npm packages in the "old" location. We will refer back to this list.
+
+ ```console
+ % npm list --global
+ /opt/homebrew/lib
+ ├── @shadowspawn/forest-arborist@12.0.0
+ └── npm@10.5.0
+ ```
+
+ We could clean out the old location first, but let's install `n` and another copy of node and see what that looks like. We end up with two versions of node, and the active one is still the Homebrew managed version.
+
+ ```console
+ % brew install n
+ % n lts
+ installing : node-v20.12.2
+ mkdir : /usr/local/n/versions/node/20.12.2
+ fetch : https://nodejs.org/dist/v20.12.2/node-v20.12.2-darwin-arm64.tar.xz
+ copying : node/20.12.2
+ installed : v20.12.2 to /usr/local/bin/node
+ active : v21.7.3 at /opt/homebrew/bin/node
+ % command -v node
+ /opt/homebrew/bin/node
+ % which -a node
+ /opt/homebrew/bin/node
+ /usr/local/bin/node
+ % command -v npm
+ /opt/homebrew/bin/npm
+ % command -v npx
+ /opt/homebrew/bin/npx
+ % n doctor
+ <...>
+
+ CHECKS
+
+ Checking n install destination is in PATH...
+ good
+
+ Checking n install destination priority in PATH...
+ ⚠️ There is a version of node installed which will be found in PATH before the n installed version.
+
+ Checking npm install destination...
+ ⚠️ There is an active version of npm shadowing the version installed by n. Check order of entries in PATH.
+ installed : /usr/local/bin/npm
+ active : /opt/homebrew/bin/npm
+
+ <...>
+ ```
+
+ Now let's switch over. Delete everything from the old location. Delete all the global npm packages _except_ npm itself, then delete npm, then delete node.
+
+ ```console
+ npm uninstall --global @shadowspawn/forest-arborist
+
+ npm uninstall --global npm
+
+ brew uninstall node
+ ```
+
+ Check the active binaries are now the ones installed by `n`:
+ ```console
+ % command -v node
+ /usr/local/bin/node
+ % command -v npm
+ /usr/local/bin/npm
+ % command -v npx
+ /usr/local/bin/npx
+ ```
+
+ And lastly, reinstall the global npm packages you started with:
+ ```
+ % npm prefix --global
+ /usr/local
+ % npm install --global npm@latest
+ % npm install --global @shadowspawn/forest-arborist
+ % npm list -g
+ /usr/local/lib
+ ├── @shadowspawn/forest-arborist@12.0.0
+ └── npm@10.5.0
+ ```
John Gee
John Gee
1 year ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.3"
+ VERSION="v9.2.4-0"
package-lock.json
Changed around line 1
- "version": "9.2.3",
+ "version": "9.2.4-0",
package.json
Changed around line 1
- "version": "9.2.3",
+ "version": "9.2.4-0",
John Gee
John Gee
1 year ago
9.2.3
package-lock.json
Changed around line 1
- "version": "9.2.3-0",
+ "version": "9.2.3",
package.json
Changed around line 1
- "version": "9.2.3-0",
+ "version": "9.2.3",
John Gee
John Gee
1 year ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [9.2.2] (2024-04-21)
+ ## [9.2.3] (2024-04-21)
- avoid problems with `curl` 8.7.1 and `--compressed` by removing option until fixed
+ ## [9.2.2] (2024-04-21)
+
+ (No changes.)
+
Changed around line 508: Only minor functional changes, but technically could break scripts relying on sp
+ [9.2.3]: https://github.com/tj/n/compare/v9.2.2...v9.2.3
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.3-0"
+ VERSION="v9.2.3"
John Gee
John Gee
1 year ago
Merge branch 'develop' of github.com:tj/n into develop
John Gee
John Gee
1 year ago
Remove use of curl --compressed due to a bug in 8.7.1 (#801)
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [9.2.2] (2024-04-21)
+
+ ### Fixed
+
+ - avoid problems with `curl` 8.7.1 and `--compressed` by removing option until fixed
Changed around line 504: Only minor functional changes, but technically could break scripts relying on sp
+ [9.2.2]: https://github.com/tj/n/compare/v9.2.1...v9.2.2
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.2-0"
+ VERSION="v9.2.2"
Changed around line 853: function do_get() {
- curl --silent --compressed "${CURL_OPTIONS[@]}" "$@"
+ curl --silent "${CURL_OPTIONS[@]}" "$@"
John Gee
John Gee
1 year ago
Post-release
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.2-0"
+ VERSION="v9.2.3-0"
package-lock.json
Changed around line 1
- "version": "9.2.2",
+ "version": "9.2.3-0",
package.json
Changed around line 1
- "version": "9.2.2",
+ "version": "9.2.3-0",
John Gee
John Gee
1 year ago
9.2.2
package-lock.json
Changed around line 1
- "version": "9.2.2-0",
+ "version": "9.2.2",
package.json
Changed around line 1
- "version": "9.2.2-0",
+ "version": "9.2.2",
John Gee
John Gee
1 year ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.1"
+ VERSION="v9.2.2-0"
package-lock.json
Changed around line 1
- "version": "9.2.1",
+ "version": "9.2.2-0",
package.json
Changed around line 1
- "version": "9.2.1",
+ "version": "9.2.2-0",
John Gee
John Gee
1 year ago
9.2.1
package-lock.json
Changed around line 1
- "version": "9.2.0",
+ "version": "9.2.1",
package.json
Changed around line 1
- "version": "9.2.0",
+ "version": "9.2.1",
John Gee
John Gee
1 year ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [9.2.1] (2024-02-25)
+
+ ### Fixed
+
+ - `n doctor` works with custom `N_CACHE_PREFIX`
+
+ ### Added
+
+ - expand tests in `n doctor` for folder existence and permissions
Changed around line 31: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ### Fixes
+ ### Fixed
- `Makefile` compatible with more flavours of `make` ([#745])
- quote paths in `Makefile` in case `PREFIX` contains spaces ([#746])
Changed around line 498: Only minor functional changes, but technically could break scripts relying on sp
+ [9.2.1]: https://github.com/tj/n/compare/v9.2.0...v9.2.1
bin/dev/release
Changed around line 18: function confirm {
- readonly N_VERSION="$(n --version)"
+ readonly N_VERSION="$(./bin/n --version)"
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.0"
+ VERSION="v9.2.1"
John Gee
John Gee
1 year ago
Rework doctor checks to support custom cache prefix (#796)
bin/n
Changed around line 1425: uninstall_installed() {
- echo "- define N_PREFIX to a writeable location, or"
+ if [[ "${N_CACHE_PREFIX}" == "${N_PREFIX}" ]]; then
+ echo "- define N_PREFIX to a writeable location, or"
+ else
+ echo "- define N_PREFIX and N_CACHE_PREFIX to writeable locations, or"
+ fi
Changed around line 1560: function show_diagnostics() {
- printf "\nChecking permissions for cache folder...\n"
- # Most likely problem is ownership rather than than permissions as such.
- local cache_root="${N_PREFIX}/n"
- if [[ -e "${N_PREFIX}" && ! -w "${N_PREFIX}" && ! -e "${cache_root}" ]]; then
- echo_red "You do not have write permission to create: ${cache_root}"
- show_permission_suggestions
- echo "- make a folder you own:"
- echo " sudo mkdir -p \"${cache_root}\""
- echo " sudo chown $(whoami) \"${cache_root}\""
- elif [[ -e "${cache_root}" && ! -w "${cache_root}" ]]; then
- echo_red "You do not have write permission to: ${cache_root}"
- show_permission_suggestions
- echo "- change folder ownership to yourself:"
- echo " sudo chown -R $(whoami) \"${cache_root}\""
- elif [[ ! -e "${cache_root}" ]]; then
- echo "Cache folder does not exist: ${cache_root}"
- echo "This is normal if you have not done an install yet, as cache is only created when needed."
- elif [[ -e "${CACHE_DIR}" && ! -w "${CACHE_DIR}" ]]; then
- echo_red "You do not have write permission to: ${CACHE_DIR}"
- show_permission_suggestions
- echo "- change folder ownership to yourself:"
- echo " sudo chown -R $(whoami) \"${CACHE_DIR}\""
- else
+ printf "\nChecking prefix folders...\n"
+ if [[ ! -e "${N_PREFIX}" ]]; then
+ echo "Folder does not exist: ${N_PREFIX}"
+ echo "- This folder will be created when you do an install."
+ fi
+ if [[ "${N_PREFIX}" != "${N_CACHE_PREFIX}" && ! -e "${N_CACHE_PREFIX}" ]]; then
+ echo "Folder does not exist: ${N_CACHE_PREFIX}"
+ echo "- This folder will be created when you do an install."
+ fi
+ if [[ -e "${N_PREFIX}" && -e "${N_CACHE_PREFIX}" ]]; then
+ if [[ -e "${N_CACHE_PREFIX}" ]]; then
+ printf "\nChecking permissions for cache folder...\n"
+ # Using knowledge cache path ends in /n/versions in following check.
+ if [[ ! -e "${CACHE_DIR}" && (( -e "${N_CACHE_PREFIX}/n" && ! -w "${N_CACHE_PREFIX}/n" ) || ( ! -e "${N_CACHE_PREFIX}/n" && ! -w "${N_CACHE_PREFIX}" )) ]]; then
+ echo_red "You do not have write permission to create: ${CACHE_DIR}"
+ show_permission_suggestions
+ echo "- make a folder you own:"
+ echo " sudo mkdir -p \"${CACHE_DIR}\""
+ echo " sudo chown $(whoami) \"${CACHE_DIR}\""
+ elif [[ ! -e "${CACHE_DIR}" ]]; then
+ echo "Cache folder does not exist: ${CACHE_DIR}"
+ echo "- This is normal if you have not done an install yet, as cache is only created when needed."
+ elif [[ ! -w "${CACHE_DIR}" ]]; then
+ echo_red "You do not have write permission to: ${CACHE_DIR}"
+ show_permission_suggestions
+ echo "- change folder ownership to yourself:"
+ echo " sudo chown -R $(whoami) \"${CACHE_DIR}\""
+ else
+ echo "good"
+ fi
+ fi
+
- # Most likely problem is ownership rather than than permissions as such.
Changed around line 1604: function show_diagnostics() {
+ if [[ ! -e "${N_PREFIX}/${subdir}" && ! -w "${N_PREFIX}" ]]; then
+ install_writeable="false"
+ echo_red "You do not have write permission to create: ${N_PREFIX}/${subdir}"
+ break
+ fi
- echo " (cd \"${N_PREFIX}\" && sudo chown -R $(whoami) bin lib include share)"
+ echo " cd \"${N_PREFIX}\""
+ echo " sudo mkdir -p bin lib include share"
+ echo " sudo chown -R $(whoami) bin lib include share"
John Gee
John Gee
1 year ago
Merge branch 'master' into develop
John Gee
John Gee
1 year ago
Add security and funding (#794)
FUNDING.yml
Changed around line 1
+ github: [tj, shadowspawn]
+ tidelift: npm/n
SECURITY.md
Changed around line 1
+ # Security Policy
+
+ ## Supported Versions
+
+ The latest two major versions get security updates.
+
+ Pull Requests for security issues will be considered for older versions.
+
+ ## Reporting a Vulnerability
+
+ To report a security vulnerability, please use the
+ [Tidelift security contact](https://tidelift.com/security).
+ Tidelift will coordinate the fix and disclosure.
John Gee
John Gee
1 year ago
Add sudo tip to proxy docs
docs/proxy-server.md
Changed around line 14: If your proxy requires authentication you can add the [url-encoded](https://urle
+ If you use `sudo` to run `n`, you need to do something extra to make the environment variables available. A simple way is to use `-E` (`--preserve-env`):
+
+ sudo -E n lts
+
John Gee
John Gee
1 year ago
Restore release version for a documentation-only update
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.1"
+ VERSION="v9.2.0"
package-lock.json
Changed around line 1
- "version": "9.2.1",
+ "version": "9.2.0",
package.json
Changed around line 1
- "version": "9.2.1",
+ "version": "9.2.0",
John Gee
John Gee
1 year ago
Restore release version for a documentation-only update
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.1-0"
+ VERSION="v9.2.1"
package-lock.json
Changed around line 1
- "version": "9.2.1-0",
+ "version": "9.2.1",
package.json
Changed around line 1
- "version": "9.2.1-0",
+ "version": "9.2.1",
John Gee
John Gee
1 year ago
Condense make instructions (#792)
README.md
Changed around line 67: Alternatively, you can clone this repo and
- 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`.
+ 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`.
John Gee
John Gee
1 year ago
Expand permissions issues coverage (#790)
README.md
Changed around line 37: If you already have Node.js installed, an easy way to install `n` is using `npm`
- The `n` command downloads and installs to `/usr/local` by default, but you may override this location by defining `N_PREFIX`.
+ The default root location used when running `n` is `/usr/local` where a normal user does not have write permission. You may strike the same sort of permission error when using npm to install global modules, like the above command. You have three main options:
+
+ 1) change the ownership of the relevant directories to yourself (see below)
+ 2) tell `n` to use a custom location where you do have write permissions (see `N_PREFIX`)
+ 3) put `sudo` in front of the command to run it as super user
+
- To avoid requiring `sudo` for `n` and `npm` global installs, it is suggested you either install to your home directory using `N_PREFIX`, or take ownership of the system directories:
+ To take ownership of the system directories (option 1):
John Gee
John Gee
1 year ago
Add --offline to README
README.md
Changed around line 215: List downloaded versions in cache:
+ Use `n` to access cached versions (already downloaded) without internet available.
+
+ n --offline 12
+
John Gee
John Gee
1 year ago
Post-release
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.2.0"
+ VERSION="v9.2.1-0"
package-lock.json
Changed around line 1
- "version": "9.2.0",
+ "version": "9.2.1-0",
package.json
Changed around line 1
- "version": "9.2.0",
+ "version": "9.2.1-0",
John Gee
John Gee
1 year ago
9.2.0
package-lock.json
Changed around line 1
- "version": "9.1.1-0",
+ "version": "9.2.0",
package.json
Changed around line 1
- "version": "9.1.1-0",
+ "version": "9.2.0",
John Gee
John Gee
1 year ago
Prepare for release
CHANGELOG.md
Changed around line 9: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [9.2.0] (2023-10-15)
+
+ ### Added
+
+ - `--offline` for resolving target version against cached downloads instead of internet lookup ([#785])
+
Changed around line 485: Only minor functional changes, but technically could break scripts relying on sp
+ [#785]: https://github.com/tj/n/pull/785
+ [9.2.0]: https://github.com/tj/n/compare/v9.1.0...v9.2.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.1.1-0"
+ VERSION="v9.2.0"
John Gee
John Gee
1 year ago
Add --offline (#785)
bin/n
Changed around line 135: g_target_node=
+ OFFLINE=false
Changed around line 394: Options:
- q, --quiet Disable curl output. Disable log messages processing "auto" and "engine" labels.
- d, --download Download if necessary, and don't make active
- a, --arch Override system architecture
+ --offline Resolve target version against cached downloads instead of internet lookup
- -all ls-remote displays all matches instead of last 20
- -insecure Turn off certificate checking for https requests (may be needed from behind a proxy server)
- -use-xz/--no-use-xz Override automatic detection of xz support and enable/disable use of xz compressed node downloads.
Changed around line 786: install() {
+ if [[ "$OFFLINE" == "true" ]]; then
+ abort "version unavailable offline"
+ fi
Changed around line 1108: function get_package_engine_version() {
+ [[ "$OFFLINE" != "true" ]] || abort "offline: an internet connection is required for looking up complex 'engine' ranges from package.json"
Changed around line 1205: function get_latest_resolved_version() {
+ elif [[ "$OFFLINE" == "true" ]]; then
+ g_target_node=$(display_local_versions "${version}")
Changed around line 1240: function display_match_limit(){
+ #
+ # Synopsis: display_local_versions version
+ #
+
+ function display_local_versions() {
+ local version="$1"
+ local match='.'
+ verbose_log "offline" "matching cached versions"
+
+ # Transform some labels before processing further.
+ if is_node_support_version "${version}"; then
+ version="$(display_latest_node_support_alias "${version}")"
+ match_count=1
+ elif [[ "${version}" = "auto" ]]; then
+ # suppress stdout logging so lsr layout same as usual for scripting
+ get_auto_version || return 2
+ version="${g_target_node}"
+ elif [[ "${version}" = "engine" ]]; then
+ # suppress stdout logging so lsr layout same as usual for scripting
+ get_engine_version || return 2
+ version="${g_target_node}"
+ fi
+
+ if [[ "${version}" = "latest" || "${version}" = "current" ]]; then
+ match='^node/.'
+ elif is_exact_numeric_version "${version}"; then
+ # Quote any dots in version so they are literal for expression
+ match="^node/${version//\./\.}"
+ elif is_numeric_version "${version}"; then
+ version="${version#v}"
+ # Quote any dots in version so they are literal for expression
+ match="${version//\./\.}"
+ # Avoid 1.2 matching 1.23
+ match="^node/${match}[^0-9]"
+ # elif is_lts_codename "${version}"; then
+ # see if demand
+ elif is_download_folder "${version}"; then
+ match="^${version}/"
+ # elif is_download_version "${version}"; then
+ # see if demand
+ else
+ abort "invalid version '$1' for offline matching"
+ fi
+
+ display_versions_paths \
+ | n_grep -E "${match}" \
+ | tail -n 1 \
+ | sed 's|node/||'
+ }
+
Changed around line 1635: while [[ $# -ne 0 ]]; do
- h|--help|help) display_help; exit ;;
- q|--quiet) set_quiet ;;
- d|--download) DOWNLOAD="true" ;;
+ --offline) OFFLINE="true" ;;
- -insecure) set_insecure ;;
- p|--preserve) N_PRESERVE_NPM="true" N_PRESERVE_COREPACK="true" ;;
- -no-preserve) N_PRESERVE_NPM="" N_PRESERVE_COREPACK="" ;;
test/tests/offline.bats
Changed around line 1
+ #!/usr/bin/env bats
+
+ load shared-functions
+ load '../../node_modules/bats-support/load'
+ load '../../node_modules/bats-assert/load'
+
+ function setup_file() {
+ unset_n_env
+ setup_tmp_prefix
+ # Note, NOT latest version of 16.
+ n --download 16.19.0
+ export N_NODE_MIRROR="https://no.internet.available"
+ }
+
+ function teardown_file() {
+ rm -rf "${TMP_PREFIX_DIR}"
+ }
+
+ function setup() {
+ hash -r
+ }
+
+ @test "n --offline 16" {
+ n --offline 16
+ hash -r
+ output="$(node --version)"
+ assert_equal "${output}" "v16.19.0"
+ rm "${TMP_PREFIX_DIR}/bin/node"
+ }
+
+ @test "n --offline latest" {
+ n --offline latest
+ hash -r
+ output="$(node --version)"
+ assert_equal "${output}" "v16.19.0"
+ rm "${TMP_PREFIX_DIR}/bin/node"
+ }
+
+ @test "n --offline run 16..." {
+ output="$(n --offline run 16 --version)"
+ assert_equal "${output}" "v16.19.0"
+ }
+
+ @test "n --offline exec 16..." {
+ output="$(n --offline exec 16 node --version)"
+ assert_equal "${output}" "v16.19.0"
+ }
+
+ @test "n --offline which 16..." {
+ output="$(n --offline which 16)"
+ assert_equal "${output}" "${TMP_PREFIX_DIR}/n/versions/node/16.19.0/bin/node"
+ }
Mark Dorison
Mark Dorison
1 year ago
Update path to Homebrew formula. (#777)
README.md
Changed around line 66: to install `n` to `bin/n` of the directory specified in the environment variable
- On macOS with [Homebrew](https://brew.sh/) you can install the [n formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/n.rb).
+ On macOS with [Homebrew](https://brew.sh/) you can install the [n formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/n/n.rb).
John Gee
John Gee
2 years ago
Post release
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.1.0"
+ VERSION="v9.1.1-0"
package-lock.json
Changed around line 1
- "version": "9.1.0",
+ "version": "9.1.1-0",
package.json
Changed around line 1
- "version": "9.1.0",
+ "version": "9.1.1-0",
John Gee
John Gee
2 years ago
9.1.0
package-lock.json
Changed around line 1
- "version": "9.0.2-0",
+ "version": "9.1.0",
package.json
Changed around line 1
- "version": "9.0.2-0",
+ "version": "9.1.0",
John Gee
John Gee
2 years ago
Update CHANGELOG and version for v9.1.0
CHANGELOG.md
Changed around line 9: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [9.1.0] (2023-04-15)
+
+ ### Added
+
+ - check for possible problem with multiple `npm` locations when running `n doctor` ([#764])
+
Changed around line 478: Only minor functional changes, but technically could break scripts relying on sp
+ [#764]: https://github.com/tj/n/pull/764
+ [9.1.0]: https://github.com/tj/n/compare/v9.0.1...v9.1.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.0.2-0"
+ VERSION="v9.1.0"
John Gee
John Gee
2 years ago
Add npm check to doctor (#764)
bin/n
Changed around line 1484: function show_diagnostics() {
+ # Check npm too. Simpler check than for PATH and node, more like the runtime logging for active/installed node.
+ if [[ -z "${N_PRESERVE_NPM}" ]]; then
+ printf "\nChecking npm install destination...\n"
+ local installed_npm="${N_PREFIX}/bin/npm"
+ local active_npm="$(command -v npm)"
+ if [[ -e "${active_npm}" && -e "${installed_npm}" && "${active_npm}" != "${installed_npm}" ]]; then
+ echo_red "There is an active version of npm shadowing the version installed by n. Check order of entries in PATH."
+ log "installed" "${installed_npm}"
+ log "active" "${active_npm}"
+ else
+ printf "good\n"
+ fi
+ fi
+
John Gee
John Gee
2 years ago
Add fedora as a second Linux for main tests (#756)
test/bin/run-all-tests
Changed around line 2
- services=( ubuntu-curl ubuntu-wget )
+ services=( fedora-curl ubuntu-wget )
test/docker-compose.yml
Changed around line 14: services:
+ fedora-curl:
+ extends:
+ file: ./docker-base.yml
+ service: testbed
+ build:
+ context: dockerfiles
+ dockerfile: Dockerfile-fedora-curl
test/dockerfiles/Dockerfile-fedora-curl
Changed around line 1
+ FROM fedora:latest
+
+ CMD ["/bin/bash"]
John Gee
John Gee
2 years ago
Update tests after old files missing (#757)
test/tests/lsr.bats
Changed around line 112: function setup() {
- @test "n=1 n lsr nightly/v10.8.1-nightly201808 # partial match" {
- output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/v10.8.1-nightly201808)"
- assert_equal "${output}" "10.8.1-nightly2018081382830a809b"
+ @test "n=1 n lsr nightly/v12.0.0-nightly2019040 # partial match" {
+ output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/v12.0.0-nightly2019040)"
+ assert_equal "${output}" "12.0.0-nightly2019040166b95362df"
- @test "n=1 n lsr nightly/7.1 # numeric match" {
- output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/7.1)"
- assert_equal "${output}" "7.1.1-nightly201611093daf11635d"
+ @test "n=1 n lsr nightly/12.0 # numeric match" {
+ output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/12.0)"
+ assert_equal "${output}" "12.0.0-nightly2019040166b95362df"
- @test "n=1 n lsr nightly/v7.1 # numeric match" {
- output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/v7.1)"
- assert_equal "${output}" "7.1.1-nightly201611093daf11635d"
+ @test "n=1 n lsr nightly/v12.0 # numeric match" {
+ output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/v12.0)"
+ assert_equal "${output}" "12.0.0-nightly2019040166b95362df"
- @test "n lsr nightly/v6.10.3-nightly2017040479546c0b5a # exact" {
- output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/v6.10.3-nightly2017040479546c0b5a)"
- assert_equal "${output}" "6.10.3-nightly2017040479546c0b5a"
+ @test "n lsr nightly/v12.0.0-nightly2019040166b95362df # exact" {
+ output="$(N_MAX_REMOTE_MATCHES=1 n lsr nightly/v12.0.0-nightly2019040166b95362df)"
+ assert_equal "${output}" "12.0.0-nightly2019040166b95362df"
John Gee
John Gee
2 years ago
Merge remote-tracking branch 'origin/master' into develop
John Gee
John Gee
2 years ago
Rework bootstrap steps to avoid temporary file
README.md
Changed around line 52: To avoid requiring `sudo` for `n` and `npm` global installs, it is suggested you
- If `npm` is not yet available, one way to bootstrap an install:
+ If `npm` is not yet available, one way to bootstrap an install is to download and run `n` directly. To install the `lts` version of Node.js:
- curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
- bash n lts
- # Now node and npm are available
+ curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts
+ # If you want n installed, you can use npm now.
John Gee
John Gee
2 years ago
Rework bootstrap steps to avoid temporary file (#754)
README.md
Changed around line 52: To avoid requiring `sudo` for `n` and `npm` global installs, it is suggested you
- If `npm` is not yet available, one way to bootstrap an install:
+ If `npm` is not yet available, one way to bootstrap an install is to download and run `n` directly. To install the `lts` version of Node.js:
- curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
- bash n lts
- # Now node and npm are available
+ curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts
+ # If you want n installed, you can use npm now.
John Gee
John Gee
2 years ago
Remove tests support for running over proxy and remove ArchLinux from tests (#750)
bin/dev/release
test/bin/proxy-build
Changed around line 0
- #!/usr/bin/env bash
- # Unoffical bash safe mode
- set -euo pipefail
- BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
- waitproxy() {
- while ! nc -z localhost 8080 ; do sleep 1 ; done
- }
-
- if nc -z localhost 8080; then
- echo "Error: port 8080 already in use. Is mitmdump already running?"
- pgrep -f -l mitmdump
- exit 2
- fi
-
- echo "Launching proxy..."
- mitmdump -w proxy~~.dump &> /dev/null &
- mitm_process="$!"
- echo "Waiting for proxy..."
- waitproxy
-
- echo "Recording downloads..."
-
- source tests/shared-functions.bash
- unset_n_env
- setup_tmp_prefix
-
- # Hack curl to avoid certificate issues with proxy
- readonly CURL_HOME="$(dirname "${BIN_DIRECTORY}")/config"
- export CURL_HOME
-
- # Go through proxy so it can record traffic, http for taobao redirects
- http_proxy="$(hostname):8080"
- export http_proxy
- https_proxy="$(hostname):8080"
- export https_proxy
-
- # Need to do wget first, as curl gets compressed index.tab which will break wget.
- # linux, archlinux-curl gets gz archives
- docker-compose run archlinux-curl /mnt/test/tests/install-reference-versions.bash
- # linux, ubuntu-curl would get compressed index and gz archives
- docker-compose run ubuntu-wget /mnt/test/tests/install-reference-versions.bash
- # native
- tests/install-reference-versions.bash
-
- rm -rf "${TMP_PREFIX_DIR}"
- echo "Stopping proxy"
- kill "${mitm_process}"
-
test/bin/proxy-run
Changed around line 0
- #!/usr/bin/env bash
- BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
- echo ""
- echo "To make use of proxy server:"
- echo " export https_proxy=\"$(hostname):8080\""
- echo " export http_proxy=\"$(hostname):8080\""
- echo " export CURL_HOME=$(dirname "${BIN_DIRECTORY}")/config"
- echo ""
-
- echo "Launching proxy server..."
- mitmdump --server-replay-nopop --server-replay proxy~~.dump
test/bin/run-all-tests
Changed around line 2
- services=( archlinux-curl ubuntu-wget )
+ services=( ubuntu-curl ubuntu-wget )
test/config/.curlrc
Changed around line 0
- # Allow use of mitm proxy
test/config/.wgetrc
Changed around line 0
- # Allow use of mitm proxy
- check_certificate = off
test/docker-base.yml
Changed around line 16: services:
- ../node_modules/bats-assert:/mnt/node_modules/bats-assert
- ../bin/n:/usr/local/bin/n
- # override settings to allow insecure connection in case using mitm proxy
- - ./config/.curlrc:/root/.curlrc
- - ./config/.wgetrc:/root/.wgetrc
- environment:
- # pass through proxy settings to allow caching proxy
- - http_proxy
- - https_proxy
test/docker-compose.yml
Changed around line 14: services:
- archlinux-curl:
- extends:
- file: ./docker-base.yml
- service: testbed
- build:
- context: dockerfiles
- dockerfile: Dockerfile-archlinux-curl
test/dockerfiles/Dockerfile-archlinux-curl
Changed around line 0
- FROM archlinux:latest
-
- CMD ["/bin/bash"]
test/tests.md
Changed around line 28: Run single test on a single system::
- ## Proxy
-
- To speed up running tests multiple times, you can optionally run a caching proxy for the node downloads. The curl settings are modified
- to allow an insecure connection through the mitm proxy.
-
- cd test
- bin/proxy-build
- bin/proxy-run
- # follow the instructions for configuring environment variables for using proxy, then run tests
-
- `node` versions added to proxy cache (and used in tests):
-
- * v4.9.1
- * lts
- * latest
-
test/tests/install-reference-versions.bash
Changed around line 0
- #!/usr/bin/env bash
-
- # These are the versions installed and hence cached by proxy-build.
-
- # Run commands we want to cache downloads for.
-
- # Get index into cache for lookups of expected versions. Uncompressed.
- curl --location --fail https://nodejs.org/dist/index.tab &> /dev/null
- curl --location --fail https://nodejs.org/download/nightly/index.tab &> /dev/null
-
- # Using 4.9.1 as a well known old version (which is no longer getting updated so does not change)
- n --download 4
- n --download lts
- n --download latest
- n --download nightly/latest
- N_NODE_MIRROR=https://npmmirror.com/mirrors/node n --download 6.11
John Gee
John Gee
2 years ago
Bump version post-release
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.0.1"
+ VERSION="v9.0.2-0"
package-lock.json
Changed around line 1
- "version": "9.0.1",
+ "version": "9.0.2-0",
package.json
Changed around line 1
- "version": "9.0.1",
+ "version": "9.0.2-0",
John Gee
John Gee
2 years ago
9.0.1
package-lock.json
Changed around line 1
- "version": "9.0.1-0",
+ "version": "9.0.1",
package.json
Changed around line 1
- "version": "9.0.1-0",
+ "version": "9.0.1",
John Gee
John Gee
2 years ago
Prepare for release
CHANGELOG.md
Changed around line 9: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [9.0.1] (2022-11-04)
+
+ ### Fixes
+
+ - `Makefile` compatible with more flavours of `make` ([#745])
+ - quote paths in `Makefile` in case `PREFIX` contains spaces ([#746])
+
Changed around line 470: Only minor functional changes, but technically could break scripts relying on sp
+ [#745]: https://github.com/tj/n/pull/745
+ [#746]: https://github.com/tj/n/pull/746
+ [9.0.1]: https://github.com/tj/n/compare/v9.0.0...v9.0.1
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.0.1-0"
+ VERSION="v9.0.1"
John Gee
John Gee
2 years ago
Add quotes to work with PREFIX containing spaces (#746)
Makefile
Changed around line 1
- mkdir -p $(PREFIX)/bin
- cp bin/n $(PREFIX)/bin/n
+ mkdir -p "$(PREFIX)/bin"
+ cp bin/n "$(PREFIX)/bin/n"
- rm -f $(PREFIX)/bin/n
+ rm -f "$(PREFIX)/bin/n"
Kaíque Kandy Koga
Kaíque Kandy Koga
2 years ago
$< make (#745) * Apparently $< is not working propertly on FreeBSD. Changing the Makefile from $< to bin/n works. * Simplify mkdir
Makefile
Changed around line 1
- mkdir -p $(PREFIX)/$(dir $<)
- cp $< $(PREFIX)/$<
+ mkdir -p $(PREFIX)/bin
+ cp bin/n $(PREFIX)/bin/n
John Gee
John Gee
2 years ago
Add codename Jod
bin/n
Changed around line 256: 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)$ ]]
+ [[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od)$ ]]
John Gee
John Gee
2 years ago
Merge branch 'master' into develop
John Gee
John Gee
2 years ago
Merge branch 'master' of github.com:tj/n
John Gee
John Gee
2 years ago
Post release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v9.0.0"
+ VERSION="v9.0.1-0"
package-lock.json
Changed around line 1
- "version": "9.0.0",
+ "version": "9.0.1-0",
package.json
Changed around line 1
- "version": "9.0.0",
+ "version": "9.0.1-0",
John Gee
John Gee
2 years ago
9.0.0
package-lock.json
Changed around line 1
- "version": "8.2.1-0",
+ "version": "9.0.0",
package.json
Changed around line 1
- "version": "8.2.1-0",
+ "version": "9.0.0",
John Gee
John Gee
2 years ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [9.0.0] (2022-07-16)
+
+ ### Changed
+
+ - `--preserve` preserves `corepack` too ([#736])
+
+ ### Added
+
+ - optional `N_PRESERVE_COREPACK` to change default behaviour for preserving `corepack` ([#736])
Changed around line 460: Only minor functional changes, but technically could break scripts relying on sp
+ [#736]: https://github.com/tj/n/pull/736
+ [9.0.0]: https://github.com/tj/n/compare/v8.2.0...v9.0.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.2.1-0"
+ VERSION="v9.0.0"
John Gee
John Gee
2 years ago
Adjust tests with updated servers and npx behaviour
test/tests/install-reference-versions.bash
Changed around line 13: n --download 4
- N_NODE_MIRROR=https://npm.taobao.org/mirrors/node n --download 6.11
+ N_NODE_MIRROR=https://npmmirror.com/mirrors/node n --download 6.11
test/tests/version-resolve-auto-engine.bats
Changed around line 162: function write_engine() {
- output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
+ # newer versions of npx not liking proxy as used in tests
+ output="$(https_proxy= n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
- output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
+ # newer versions of npx not liking proxy as used in tests
+ output="$(https_proxy= n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
- output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
+ # newer versions of npx not liking proxy as used in tests
+ output="$(https_proxy= n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
John Gee
John Gee
2 years ago
Add N_PRESERVE_COREPACK (#736)
README.md
Changed around line 179: Or execute a command with `PATH` modified so `node` and `npm` will be from the d
- A Node.js install normally includes `npm` as well, but you may wish to preserve an updated `npm` and `npx` leaving them out of the install using `--preserve`:
+ A Node.js install normally also includes `npm`, `npx`, and `corepack`, but you may wish to preserve your current (especially newer) versions using `--preserve`:
+ # Node.js 8.17.0 includes (older) npm 6.13.4
- You can make this the default by setting `N_PRESERVE_NPM` to a non-empty string.
+ You can make this the default by setting the environment variable to a non-empty string. There are separate environment variables for `npm` and `corepack`:
+ export N_PRESERVE_COREPACK=1
- You can be explicit to get the desired behaviour whatever the environment variable:
+ You can be explicit to get the desired behaviour whatever the environment variables:
Changed around line 278: In brief:
- support for [NO_COLOR](https://no-color.org) and [CLICOLOR=0](https://bixense.com/clicolors) for controlling use of ANSI color codes
- `N_MAX_REMOTE_MATCHES` to change the default `ls-remote` maximum of 20 matching versions
- `N_PRESERVE_NPM`: See [Preserving npm](#preserving-npm)
+ - `N_PRESERVE_COREPACK`: See [Preserving npm](#preserving-npm)
bin/n
Changed around line 695: activate() {
- if [[ -e "$dir/lib/node_modules/corepack" ]]; then
+ if [[ -e "$dir/lib/node_modules/corepack" && -z "${N_PRESERVE_COREPACK}" ]]; then
Changed around line 707: activate() {
- [[ -e "$dir/bin/corepack" ]] && cp -fR "$dir/bin/corepack" "$N_PREFIX/bin" # from 16.9.0
+ if [[ -z "${N_PRESERVE_COREPACK}" ]]; then
+ [[ -e "$dir/bin/corepack" ]] && cp -fR "$dir/bin/corepack" "$N_PREFIX/bin" # from 16.9.0
+ fi
Changed around line 1424: function show_diagnostics() {
+ [[ -n "${N_PRESERVE_COREPACK}" ]] && echo "installs preserve corepack by default"
Changed around line 1564: while [[ $# -ne 0 ]]; do
- q|--quiet) set_quiet ;;
- d|--download) DOWNLOAD="true" ;;
- -insecure) set_insecure ;;
- -p|--preserve) N_PRESERVE_NPM="true" ;;
- --no-preserve) N_PRESERVE_NPM="" ;;
+ -p|--preserve) N_PRESERVE_NPM="true" N_PRESERVE_COREPACK="true" ;;
+ --no-preserve) N_PRESERVE_NPM="" N_PRESERVE_COREPACK="" ;;
- -use-xz) N_USE_XZ="true" ;;
- -no-use-xz) N_USE_XZ="false" ;;
- -latest) display_remote_versions latest; exit ;;
test/tests/shared-functions.bash
Changed around line 13: function unset_n_env(){
+ unset N_PRESERVE_COREPACK
Sukka
Sukka
3 years ago
Chore: replace `git.io` in installation guide (#724) https://github.com/mklement0/n-install/commit/d6f6db0b8eaf25b3faa513135675f86b0fdcb4e4
README.md
Changed around line 77: Or on macOS with [MacPorts](https://www.macports.org/) you can install the [n po
- curl -L https://git.io/n-install | bash
+ curl -L https://bit.ly/n-install | bash
John Gee
John Gee
3 years ago
Post release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.2.0"
+ VERSION="v8.2.1-0"
package-lock.json
Changed around line 1
- "version": "8.2.0",
+ "version": "8.2.1-0",
package.json
Changed around line 1
- "version": "8.2.0",
+ "version": "8.2.1-0",
John Gee
John Gee
3 years ago
8.2.0
package-lock.json
Changed around line 1
- "version": "8.1.1-0",
+ "version": "8.2.0",
package.json
Changed around line 1
- "version": "8.1.1-0",
+ "version": "8.2.0",
John Gee
John Gee
3 years ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [8.2.0] (2022-04-18)
+
+ ### Added
+
+ - log before copying files during install ([#720])
Changed around line 449: Only minor functional changes, but technically could break scripts relying on sp
+ [#720]: https://github.com/tj/n/issues/720
+ [8.2.0]: https://github.com/tj/n/compare/v8.1.0...v8.2.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.1.1-0"
+ VERSION="v8.2.0"
John Gee
John Gee
3 years ago
Add log before copying during install
bin/n
Changed around line 672: activate() {
+ log "copying" "$version"
+
John Gee
John Gee
3 years ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.1.0"
+ VERSION="v8.1.1-0"
package-lock.json
Changed around line 1
- "version": "8.1.0",
+ "version": "8.1.1-0",
package.json
Changed around line 1
- "version": "8.1.0",
+ "version": "8.1.1-0",
John Gee
John Gee
3 years ago
8.1.0
package-lock.json
Changed around line 1
- "version": "8.0.3-0",
+ "version": "8.1.0",
package.json
Changed around line 1
- "version": "8.0.3-0",
+ "version": "8.1.0",
John Gee
John Gee
3 years ago
Prepeare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## Unreleased (date goes here)
+ ## [8.1.0] (2022-03-18)
+
+ ### Added
+
+ - optional `N_CACHE_PREFIX` for separate location for downloaded files than install location ([#717])
Changed around line 442: Only minor functional changes, but technically could break scripts relying on sp
+ [#717]: https://github.com/tj/n/issues/717
+ [8.1.0]: https://github.com/tj/n/compare/v8.0.2...v8.1.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.0.3-0"
+ VERSION="v8.1.0"
Gordon Bleux
Gordon Bleux
3 years ago
Make cache directory configurable (#717) Read the cache directory from the environment, falling back to a location under `N_PREFIX`
README.md
Changed around line 255: 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.
+
bin/n
Changed around line 66: VERSION="v8.0.3-0"
- readonly CACHE_DIR=$N_PREFIX/n/versions
+
+ N_CACHE_PREFIX="${N_CACHE_PREFIX-${N_PREFIX}}"
+ N_CACHE_PREFIX=${N_CACHE_PREFIX%/}
+ CACHE_DIR="${N_CACHE_PREFIX}/n/versions"
+ readonly N_CACHE_PREFIX CACHE_DIR
test/tests/install-contents.bats
Changed around line 42: function setup() {
+
+ @test "install: cache prefix" {
+ readonly N_CACHE_PREFIX="$(mktemp -d)"
+ readonly TARGET_VERSION="4.9.1"
+ setup_tmp_prefix
+ export N_CACHE_PREFIX
+
+ [ ! -d "${N_CACHE_PREFIX}/n/versions/node/${TARGET_VERSION}" ]
+ [ ! -d "${N_PREFIX}/n/versions/node/${TARGET_VERSION}" ]
+
+ n ${TARGET_VERSION}
+
+ # Cached version
+ [ -d "${N_CACHE_PREFIX}/n/versions/node/${TARGET_VERSION}" ]
+ [ ! -d "${N_PREFIX}/n/versions/node/${TARGET_VERSION}" ]
+
+ rm -rf "${TMP_PREFIX_DIR}" "${N_CACHE_PREFIX}"
+ }
test/tests/shared-functions.bash
Changed around line 7
+ unset N_CACHE_PREFIX
John Gee
John Gee
3 years ago
Merge remote-tracking branch 'origin/master' into develop
华晨
华晨
3 years ago
Update China Mirror URL to the New Version (#708) npm.taobao.org is now redirect to npmmirror.com, use the new URL instead.
README.md
Changed around line 223: Display diagnostics to help resolve problems:
- export N_NODE_MIRROR=https://npm.taobao.org/mirrors/node
+ export N_NODE_MIRROR=https://npmmirror.com/mirrors/node
John Gee
John Gee
3 years ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## Unreleased (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.0.2"
+ VERSION="v8.0.3-0"
package-lock.json
Changed around line 1
- "version": "8.0.2",
+ "version": "8.0.3-0",
package.json
Changed around line 1
- "version": "8.0.2",
+ "version": "8.0.3-0",
John Gee
John Gee
3 years ago
8.0.2
package-lock.json
Changed around line 1
- "version": "8.0.2-0",
+ "version": "8.0.2",
package.json
Changed around line 1
- "version": "8.0.2-0",
+ "version": "8.0.2",
John Gee
John Gee
3 years ago
Add quoting (per ShellCheck)
bin/n
Changed around line 1273: function display_remote_versions() {
- version="${version#${g_mirror_folder_name}/}"
+ version="${version#"${g_mirror_folder_name}"/}"
John Gee
John Gee
3 years ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [8.0.2] (2022-01-09)
- ## [8.0.1] (2011-12-04)
+ ### Fixed
+
+ - improved warning message when utility location hash may be holding old location to cover a wider range of shells including dash ([#707])
+
+ ## [8.0.1] (2021-12-04)
Changed around line 435: Only minor functional changes, but technically could break scripts relying on sp
+ [#707]: https://github.com/tj/n/issues/707
+ [8.0.2]: https://github.com/tj/n/compare/v8.0.1...v8.0.2
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.0.2-0"
+ VERSION="v8.0.2"
Alfonso Gómez-Arzola
Alfonso Gómez-Arzola
3 years ago
GH-706 Update location change message (#707) * GH-706 Update location change message * Remove (seemingly) unnecessary shellcheck exception * Add missing trailing newline
bin/n
Changed around line 740: activate() {
- # shellcheck disable=SC2016
- printf 'To reset the command location hash either start a new shell, or execute PATH="$PATH"\n'
+ printf 'If "node --version" shows the old version then start a new shell, or reset the location hash with:\nhash -r (for bash, zsh, ash, dash, and ksh)\nrehash (for csh and tcsh)\n'
John Gee
John Gee
3 years ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.0.1"
+ VERSION="v8.0.2-0"
package-lock.json
Changed around line 1
- "version": "8.0.1",
+ "version": "8.0.2-0",
package.json
Changed around line 1
- "version": "8.0.1",
+ "version": "8.0.2-0",
John Gee
John Gee
3 years ago
8.0.1
package-lock.json
Changed around line 1
- "version": "8.0.1-0",
+ "version": "8.0.1",
package.json
Changed around line 1
- "version": "8.0.1-0",
+ "version": "8.0.1",
John Gee
John Gee
3 years ago
Prepeare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [8.0.1] (2011-12-04)
+
+ ### Fixed
+
+ - improve error handling for tar extraction errors ([#701])
+ - add tar flag for compatibility with tar builds which do not default to stdin ([#697])
Changed around line 427: Only minor functional changes, but technically could break scripts relying on sp
+ [#697]: https://github.com/tj/n/issues/697
+ [#701]: https://github.com/tj/n/issues/701
+ [8.0.1]: https://github.com/tj/n/compare/v8.0.0...v8.0.1
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.0.1-0"
+ VERSION="v8.0.1"
John Gee
John Gee
3 years ago
Add check for tar error (e.g. decompression problem) (#701)
bin/n
Changed around line 762: install() {
+ # Note: decompression flags ignored with default Darwin tar which autodetects.
Changed around line 791: install() {
- if [[ "${PIPESTATUS[0]}" -ne 0 ]]; then
+ pipe_results=( "${PIPESTATUS[@]}" )
+ if [[ "${pipe_results[0]}" -ne 0 ]]; then
+ if [[ "${pipe_results[1]}" -ne 0 ]]; then
+ abort "failed to extract archive for $version"
+ fi
John Gee
John Gee
3 years ago
Explicitly tell tar to read from stdin (#697)
bin/n
Changed around line 789: install() {
- do_get "${url}" | tar "$tarflag" --strip-components=1 --no-same-owner
+ do_get "${url}" | tar "$tarflag" --strip-components=1 --no-same-owner -f -
Kerollos Magdy
Kerollos Magdy
3 years ago
Fix a typo in a comment (#695)
bin/n
Changed around line 337: enter_fullscreen() {
- # Restore screen contentsq
+ # Restore screen contents
John Gee
John Gee
3 years ago
Post-release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v8.0.0"
+ VERSION="v8.0.1-0"
package-lock.json
Changed around line 1
- "version": "8.0.0",
+ "version": "8.0.1-0",
package.json
Changed around line 1
- "version": "8.0.0",
+ "version": "8.0.1-0",
John Gee
John Gee
3 years ago
8.0.0
package-lock.json
Changed around line 1
- "version": "7.5.1-0",
+ "version": "8.0.0",
package.json
Changed around line 1
- "version": "7.5.1-0",
+ "version": "8.0.0",
John Gee
John Gee
3 years ago
Prepare for release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ## [Unreleased] (date goes here)
+ ## [8.0.0] (2021-10-23)
+
+ ### Changed
+
+ - display error if version missing in version file for `n auto` and `n engine` (rather than fallback to current) ([#693])
Changed around line 419: Only minor functional changes, but technically could break scripts relying on sp
+ [#693]: https://github.com/tj/n/issues/693
+ [8.0.0]: https://github.com/tj/n/compare/v7.5.0...v8.0.0
bin/n
Changed around line 61: function n_grep() {
- VERSION="v7.5.1-0"
+ VERSION="v8.0.0"
John Gee
John Gee
3 years ago
Fail for blank target from auto (or engine) version file (#693) * Fail unspecified auto rather than fall back to current * Simplify wording
bin/n
Changed around line 1071: function get_package_engine_version() {
- if [[ -z "${range}" || "*" == "${range}" ]]; then
+ [[ -n "${range}" ]] || return 2
+ if [[ "*" == "${range}" ]]; then
Changed around line 1143: function get_engine_version() {
+ [[ -n "${g_target_node}" ]] || abort "did not find supported version of node in 'engines' field of package.json"
Changed around line 1171: function get_auto_version() {
+ [[ -n "${g_target_node}" ]] || abort "file found for auto did not contain target version of node"
John Gee
John Gee
3 years ago
Post release
CHANGELOG.md
Changed around line 7: and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ ## [Unreleased] (date goes here)
+
bin/n
Changed around line 61: function n_grep() {
- VERSION="v7.5.0"
+ VERSION="v7.5.1-0"
package-lock.json
Changed around line 1
- "version": "7.5.0",
+ "version": "7.5.1-0",
package.json
Changed around line 1
- "version": "7.5.0",
+ "version": "7.5.1-0",