Changes to n

Helber Belmiro
Helber Belmiro
7 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
8 months 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
9 months 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
9 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
- ## [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
9 months ago
Merge branch 'develop' of github.com:tj/n into develop
John Gee
John Gee
9 months 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
9 months 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
9 months 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
11 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="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
11 months 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",