nvm
nvm copied to clipboard
Cannot install node on macOS
Operating system and version:
nvm debug output:
nvm --version: v0.39.2
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'kret'
${HOME}: /Users/kret
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.nix-profile/bin:${HOME}/.opam/default/bin:${HOME}/.rbenv/shims:${NVM_DIR}/versions/node/v18.10.0/bin:${HOME}/.jenv/shims:${HOME}/.asdf/shims:/usr/local/opt/asdf/libexec/bin:${HOME}/bin:${HOME}/.cabal/bin:${HOME}/.ghcup/bin:${HOME}/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-apple-darwin21.0)'
uname -a: 'Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64'
checksum binary: 'sha256sum'
OS version: macOS 12.6 21G115
curl: /usr/bin/curl, curl 7.79.1 (x86_64-apple-darwin21.0) libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.45.1
wget: not found
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: rm: aliased to rm -i (rm -i)
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.38.1
ls: grep:: No such file or directory
grep: grep: aliased to grep --color (grep --color), grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
awk: /usr/bin/awk, awk version 20200816
nvm current: v18.10.0
which node: ${NVM_DIR}/versions/node/v18.10.0/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v18.10.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v18.10.0
npm root -g: ${NVM_DIR}/versions/node/v18.10.0/lib/node_modules
nvm ls output:
v16.13.1
-> v18.10.0
system
default -> node (-> v18.10.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.10.0) (default)
stable -> 18.10 (-> v18.10.0) (default)
lts/* -> lts/gallium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.20.1 (-> N/A)
lts/gallium -> v16.18.0 (-> N/A)
How did you install nvm?
Install script in readme, v0.35.1, kept updated via zsh-nvm plugin.
What steps did you perform?
Ran nvm install node --reinstall-packages-from=node and instead of usual installation of node a very long error output was displayed (see next section).
Same thing happened when using other recent node version numbers: 16, 17, 18.
Also when I removed the --reinstall-packages-from parameter.
Also when I run nvm install -b node.
What happened?
Downloading and installing node v19.0.0...
awk: non-terminated string node-v19.0... at source line 1
context is
{ if ("node-v19.0.0-darwin-integer 10 readonly '!'=74621 >>>
<<<
awk: non-terminated string node-v19.0... at source line 2
awk: non-terminated string node-v19.0... at source line 3
mkdir: /Users/kret/.nvm/.cache/bin/node-v19.0.0-darwin-integer 10 readonly '!'=74621
integer 10 readonly '#'=0
integer 10 readonly '$'=74222
array readonly '*'=( )
readonly -=3569JNRXghikls
0=nvm_get_arch
integer 10 readonly '?'=0
array readonly @=( )
local ADDITIONAL_PARAMETERS=''
ALACRITTY_LOG=: File name too long
creating directory /Users/kret/.nvm/.cache/bin/node-v19.0.0-darwin-integer 10 readonly '!'=74621
...
...goes on for maaany lines
...
Eventually requested node version was not installed.
What did you expect to happen?
I expected the requested binary node distribution of Mac OS to be downloaded, installed and made available via nvm, as usually so far.
Is there anything in any of your profile files that modifies the PATH?
In my .zshrc I have at the top: export PATH=$HOME/bin:$HOME/.cabal/bin:$HOME/.ghcup/bin:$HOME/.local/bin:$PATH
If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?
Any idea what "ALACRITTY_LOG" is?
I see some nix stuff in your path; do you have any of the standard posix tools, or the compiler tools node needs to be installed, or node/npm, installed via nix?
Oh - you may be using a very very old version of nvm. We're up to v0.39.2 now, can you update and try again? (altho nvm debug indicates the correct version)
Any idea what "ALACRITTY_LOG" is?
Alacritty is terminal emulator I use (https://github.com/alacritty/alacritty). That must be something it sets...
I checked under regular macOS Terminal app and that produces same result.
Generally the error output is full of env-like output - looks like all env vars, shell functions etc listed. I only pasted the top bit. It seemed to me that the part about awk error is the most promising message.
I see some nix stuff in your path; do you have any of the standard posix tools, or the compiler tools node needs to be installed, or node/npm, installed via nix?
No, I generally don't use nix. Installed to try and nothing more.
Oh - you may be using a very very old version of nvm. We're up to v0.39.2 now, can you update and try again? (altho
nvm debugindicates the correct version)
I use nvm v0.39.2 - I just copy-pasted the original install command that I used, and also mentioned that I kept nvm updated via zsh-nvm plugin. Maybe that was too much noise, sorry.
I'm not familiar with alacritty, but if it's emulating a terminal incorrectly, then there'd be all sorts of errors. In particular, if its awk isn't posix-compliant.
That it's outputting superfluous data is actually pretty concerning; the implication is that it's wrapping standard things or providing nonstandard things.
I'm not familiar with alacritty, but if it's emulating a terminal incorrectly, then there'd be all sorts of errors. In particular, if its awk isn't posix-compliant. That it's outputting superfluous data is actually pretty concerning; the implication is that it's wrapping standard things or providing nonstandard things.
Alacritty should not influence this. As I wrote, when I ran same nvm install command in standard macOS Terminal app I see same awk error (sure, the "env" output does not contain Alaritty env vars, but it does contains all others).
I have also tried on my work laptop with Windows 11 and WSL Ubuntu - with exactly same effect.
Ok, thanks for confirming!
it’s possible this is related to #2914, and will be fixed in the next release.
Workaround: I disabled the oh-my-zsh in my shell I was able to install new node version using the original command.
@kret in omz, what was the output of setopt? if i know what zsh flag broke it, i can work around it in nvm.
Thanks!
Here is the output of my setopt:
alwaystoend
autocd
autopushd
combiningchars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
interactive
interactivecomments
login
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
I only have these on my stock zsh:
combiningchars
interactive
monitor
shinstdin
zle
Any chance you could do a binary search and figure out which option is breaking it?
It looks like setopt is not the culprit - I have run a plain zsh shell (commented out everything in my .zshrc except nvm init), set all the same setopt options as in omz (listed in my previous comment) and run the nvm install ... command - which completed successfully.
oh weird, ok - maybe the nvm debug output is different on both?
nvm debug output in "raw zsh" shell:
nvm --version: v0.39.2
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'kret'
${HOME}: /Users/kret
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v19.2.0/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-apple-darwin22.0)'
uname -a: 'Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64'
checksum binary: 'sha256sum'
OS version: macOS 13.0.1 22A400
curl: /usr/bin/curl, curl 7.84.0 (x86_64-apple-darwin22.0) libcurl/7.84.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0
wget: not found
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.38.1
grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
awk: /usr/bin/awk, awk version 20200816
nvm current: v19.2.0
which node: ${NVM_DIR}/versions/node/v19.2.0/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v19.2.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v19.2.0
npm root -g: ${NVM_DIR}/versions/node/v19.2.0/lib/node_modules
The difference to the omz one is the in omz: different PATH, rm is an alias to rm -i, grep is an alias to grep --color and there is an extra line in the output: ls: grep:: No such file or directory. No other differences.
Hmm - it's worth trying to unalias one of rm or grep and see if that fixes it.
Unaliasing rm and grep does not help.
Seems like similar to #2963
Agreed. Commenting out common-aliases plugin from .zshrc allows node installation to succeed.
I don't have common-aliases for a zsh plugin and I'm experiencing the same issue.. I use iTerm, but confirmed that Terminal also exhibits the same behavior.
I debugged my .zshrc via un/commenting. It turns out that I had a custom alias for the single character L. Got rid of that it was working properly. Looks like the similar issue talked about L as a problem alias (see https://github.com/nvm-sh/nvm/issues/2963#issuecomment-1336526069)