From 3243f7a08272a5f973a92fec781589e98f9f47b7 Mon Sep 17 00:00:00 2001 From: "Brandon L. Reiss" Date: Wed, 27 Jan 2021 13:12:17 -0500 Subject: [PATCH 1/6] [Fix] Fix potential unbound var error on nvm install Fixes #2420. When using `nvm install` with an already installed version, Bash (and potentially other shells) may emit an unbound variable error when `set -u` is set. The presence of the error depends on specific shell versions, but appears to happen in MacOS 11.1 (Big Sur) using a recent Bash version installed via Homebrew (as of this writing). The fix accesses `ALIAS` correctly for the case where it is not set by an `alias` option to `nvm install`. --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 8d57cae..e0eccfe 100644 --- a/nvm.sh +++ b/nvm.sh @@ -3078,7 +3078,7 @@ nvm() { nvm_ensure_default_set "${provided_version}" fi - if [ -n "${ALIAS}" ]; then + if [ -n "${ALIAS-}" ]; then nvm alias "${ALIAS}" "${provided_version}" fi From 49e806c77a7b4d42ed2fc411444c97b801bc529b Mon Sep 17 00:00:00 2001 From: Matt Calthrop Date: Thu, 21 Jan 2021 20:45:12 +0000 Subject: [PATCH 2/6] [readme] Add macOS troubleshooting instructions for M1 chip --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/README.md b/README.md index 53b3710..4ffc28f 100644 --- a/README.md +++ b/README.md @@ -871,3 +871,55 @@ Ignore insecure directories and continue [y] or abort compinit [n]? y ``` Homebrew causes insecure directories like `/usr/local/share/zsh/site-functions` and `/usr/local/share/zsh`. This is **not** an `nvm` problem - it is a homebrew problem. Refer [here](https://github.com/zsh-users/zsh-completions/issues/680) for some solutions related to the issue. + +**Macs with M1 chip** + +_January 2021:_ there are no pre-compiled NodeJS binaries for versions prior to 15.x for Apple's new M1 chip (arm64 architecture). + +Some issues you may encounter: + +- using `nvm` to install, say, `v14.15.4`: + - the C code compiles successfully + - but crashes with an out of memory error when used + - increasing the memory available to node still produces the out of memory errors: + ```sh + $ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package + ``` +- when using `nvm` to install some versions, the compilation fails + +One solution to this issue is to change the architecture of your shell from arm64 to x86. + +Let's assume that: +- you already have versions `12.20.1` and `14.15.4` installed using `nvm` +- the current version in use is `14.15.4` +- you are using the `zsh` shell + +```sh +# Check what version you're running: +$ node --version +v14.15.4 +# Check architecture of the `node` binary: +$ node -p process.arch +arm64 +# This confirms that the arch is for the M1 chip, which is causing the problems. +# So we need to uninstall it. +# We can't uninstall the version we are currently using, so switch to another version: +$ nvm install v12.20.1 +# Now uninstall the version we want to replace: +$ nvm uninstall v14.15.4 +# Set the architecture for our shell to 64-bit X86: +$ arch -x86_64 zsh +``` + +At this point in time, we are still in the shell that is running using the M1 architecture. + +So we now need to open a new terminal window in order to run our shell in the 64-bit X86 architecture. + +```sh +# `node` will not be on the path in this new terminal window. +# So install it: +$ nvm install v14.15.4 +# Now check that the architecture is correct: +$ node -p process.arch +x64 +``` From 4c11ab1ac63cdd1d0dfc8e87b7c655d17d28401a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Feb 2021 14:32:35 -0800 Subject: [PATCH 3/6] [actions] update workflows --- .github/workflows/release.yml | 2 +- .github/workflows/toc.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0db844..596a040 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v2 with: node-version: "14" - run: npm install diff --git a/.github/workflows/toc.yml b/.github/workflows/toc.yml index 879e409..55ea20f 100644 --- a/.github/workflows/toc.yml +++ b/.github/workflows/toc.yml @@ -17,7 +17,7 @@ jobs: # pulls all tags (needed for lerna / semantic release to correctly version) - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: '12.x' - run: npm install From 0d14d7f6b7ae615f06aae27de574cf6115170ef3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Feb 2021 14:31:06 -0800 Subject: [PATCH 4/6] [Dev Deps] update `doctoc`, `replace`, `semver` --- Makefile | 2 +- package.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index db0c21f..cc2944b 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,6 @@ release: _ensure-tag _ensure-clean _ensure-current-version new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ fi; \ printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ - replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + replace "$$old_ver" "$$new_ver" $(VERSIONED_FILES) && \ git commit -m "v$$new_ver" $(VERSIONED_FILES) && \ git tag -a "v$$new_ver" diff --git a/package.json b/package.json index 1c683bb..f520f7e 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,10 @@ "homepage": "https://github.com/nvm-sh/nvm", "devDependencies": { "dockerfile_lint": "^0.3.2", - "doctoc": "^1.2.0", + "doctoc": "^2.0.0", "eclint": "^2.6.0", - "replace": "^0.3.0", - "semver": "^5.0.1", + "replace": "^1.2.0", + "semver": "^7.3.4", "urchin": "^0.0.5" } } From 0fad5ec5755c0519ff30182b69761c84abca9f2b Mon Sep 17 00:00:00 2001 From: Arshath Date: Fri, 5 Feb 2021 19:45:26 +0530 Subject: [PATCH 5/6] [readme] quote asterisk in shell command on `--latest-npm` example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ffc28f..cc6054d 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,7 @@ Note that reinstalling packages _explicitly does not update the npm version_ — To update npm at the same time add the `--latest-npm` flag, like this: ```sh -nvm install lts/* --reinstall-packages-from=default --latest-npm +nvm install 'lts/*' --reinstall-packages-from=default --latest-npm ``` or, you can at any time run the following command to get the latest supported npm version on the current node version: From d5c1441a83e456da1b01638742841034705ccbf4 Mon Sep 17 00:00:00 2001 From: David Zulaica Date: Sat, 13 Feb 2021 03:41:41 -0800 Subject: [PATCH 6/6] [readme] Update M1 macOS troubleshooting instructions --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cc6054d..d391342 100644 --- a/README.md +++ b/README.md @@ -909,17 +909,11 @@ $ nvm install v12.20.1 $ nvm uninstall v14.15.4 # Set the architecture for our shell to 64-bit X86: $ arch -x86_64 zsh -``` - -At this point in time, we are still in the shell that is running using the M1 architecture. - -So we now need to open a new terminal window in order to run our shell in the 64-bit X86 architecture. - -```sh -# `node` will not be on the path in this new terminal window. -# So install it: +# Install node using nvm. This should download the precompiled x64 binary: $ nvm install v14.15.4 # Now check that the architecture is correct: $ node -p process.arch x64 +# It is now safe to revert zsh back to the native architecture: +$ arch -arm64 zsh ```