nvm
nvm copied to clipboard
Can't install node on WSL2
Hi, I updated WSL to WSL2 and try to install the nvm again.
Operating system and version:
Windows 10 20H2 (OS Build 19042.746) Using WSL 2 => Ubuntu-20.04
nvm debug output:
nvm --version: v0.37.2
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'julias'
${HOME}: /home/julias
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/c/WINDOWS/System32/OpenSSH/:/c/Program Files/Intel/WiFi/bin/:/c/Program Files/Common Files/Intel/WirelessCommon/:/c/Program Files (x86)/Pulse Secure/VC142.CRT/X64/:/c/Program Files (x86)/Pulse Secure/VC142.CRT/X86/:/c/Users/julia.s/AppData/Local/Microsoft/WindowsApps:/c/Users/julia.s/AppData/Local/hyper/app-3.0.2/resources/bin:/c/Users/julia.s/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 20.04 LTS
curl: /usr/bin/curl, curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.20.3 built on linux-gnu.
git: /usr/bin/git, git version 2.25.1
grep: /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.4
awk: /usr/bin/awk, GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
sed: /usr/bin/sed, sed (GNU sed) 4.7
cut: /usr/bin/cut, cut (GNU coreutils) 8.30
basename: /usr/bin/basename, basename (GNU coreutils) 8.30
rm: /usr/bin/rm, rm (GNU coreutils) 8.30
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.30
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0
nvm current: none
which node:
which iojs:
which npm:
npm config get prefix:
Command 'npm' not found, but can be installed with:
sudo apt install npm
npm root -g:
Command 'npm' not found, but can be installed with:
sudo apt install npm
nvm ls output:
N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/fermium (-> 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.23.2 (-> N/A)
lts/erbium -> v12.20.1 (-> N/A)
lts/fermium -> v14.15.4 (-> N/A)
How did you install nvm?
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
What steps did you perform?
nvm install node
What happened?
awk: fatal: cannot open file `-' for reading (No such file or directory)
awk: fatal: cannot open file `-' for reading (No such file or directory)
Version 'node' not found - try `nvm ls-remote` to browse available versions.
ALSO for
nvm install --lts
I get:
Installing latest LTS version.
awk: fatal: cannot open file `-' for reading (No such file or directory)
Version '' (with LTS filter) not found - try `nvm ls-remote --lts` to browse available versions
FOR:
nvm ls-remote
I get:
awk: fatal: cannot open file `-' for reading (No such file or directory)
awk: fatal: cannot open file `-' for reading (No such file or directory)
N/A
What did you expect to happen?
installing the latest version of node
Is there anything in any of your profile files that modifies the PATH?
No.
If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?
* Trying 104.20.22.46:443...
* TCP_NODELAY set
* Connected to nodejs.org (104.20.22.46) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.nodejs.org
* start date: Oct 21 00:00:00 2019 GMT
* expire date: Jan 18 23:59:59 2022 GMT
* subjectAltName: host "nodejs.org" matched cert's "nodejs.org"
* issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55b65cb43800)
> HEAD /dist/ HTTP/2
> Host: nodejs.org
> user-agent: curl/7.68.0
> accept: */*
> accept-encoding: deflate, gzip, br
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
HTTP/2 200
< date: Tue, 09 Feb 2021 09:13:36 GMT
date: Tue, 09 Feb 2021 09:13:36 GMT
< content-type: text/html
content-type: text/html
< set-cookie: __cfduid=da21d81b5a2eca11f3e3941049f6ae3381612862016; expires=Thu, 11-Mar-21 09:13:36 GMT; path=/; domain=.nodejs.org; HttpOnly; SameSite=Lax
set-cookie: __cfduid=da21d81b5a2eca11f3e3941049f6ae3381612862016; expires=Thu, 11-Mar-21 09:13:36 GMT; path=/; domain=.nodejs.org; HttpOnly; SameSite=Lax
< cache-control: max-age=14400
cache-control: max-age=14400
< cf-cache-status: HIT
cf-cache-status: HIT
< age: 8600
age: 8600
< cf-request-id: 0827aa65a20000d6fd3b1fd000000001
cf-request-id: 0827aa65a20000d6fd3b1fd000000001
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< vary: Accept-Encoding
vary: Accept-Encoding
< server: cloudflare
server: cloudflare
< cf-ray: 61ec79b5dc00d6fd-FRA
cf-ray: 61ec79b5dc00d6fd-FRA
< content-encoding: br
content-encoding: br
<
* Connection #0 to host nodejs.org left intact
This is confusing :-/ it's not clear which awk invocation is erroring out, but also, all of them are perfectly valid and seem to be working for every other user.
Presumably nvm_ls_remote gives you the same error - if so, what does nvm_ls_remote_index_tab node std do?
Hi, I don't understand which command should I need to do? I didn't see it on the nvm --help and I tried also to run it this way:
nvm_ls_remote_index_tab node std
But I got:
not enough arguments
Right, these are internal commands that will help me debug, but aren’t part of the api.
try nvm_ls_remote_index_tab node std 15?
julias@julia-lp:/$ nvm_ls_remote_index_tab node std 15
v15.0.0
v15.0.1
v15.1.0
v15.2.0
v15.2.1
v15.3.0
v15.4.0
v15.5.0
v15.5.1
v15.6.0
v15.7.0
v15.8.0
and I could also install node version, but unfortunately, after reboot my computer, I got this:
julias@julia-lp:~$ nvm_ls_remote_index_tab node std 15
awk: fatal: cannot open file `-' for reading (No such file or directory)
N/A
I'm trying to figure why it worked, and now it's not.
Hi, I think it might be related to TMPDIR.
julias@julia-lp:~$ nvm install --lts
Installing latest LTS version.
awk: fatal: cannot open file `-' for reading (No such file or directory)
Version '' (with LTS filter) not found - try `nvm ls-remote --lts` to browse available versions.
julias@julia-lp:~$ TMPDIR=/root nvm install --lts
Installing latest LTS version.
Downloading and installing node v14.15.5...
Local cache found: ${NVM_DIR}/.cache/bin/node-v14.15.5-linux-x64/node-v14.15.5-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v14.15.5-linux-x64/node-v14.15.5-linux-x64.tar.xz
Now using node v14.15.5 (npm v6.14.11)
julias@julia-lp:~$ nvm list
v12.20.0
-> v14.15.5
system
default -> 12.20.0 (-> v12.20.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.15.5) (default)
stable -> 14.15 (-> v14.15.5) (default)
lts/* -> lts/fermium (-> v14.15.5)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.3 (-> N/A)
lts/erbium -> v12.20.1 (-> N/A)
lts/fermium -> v14.15.5
julias@julia-lp:~$
I assigned TMPDIR in the .bashrc file to a different path located in /mnt/c/Users/julia.s/AppData/Local/Temp (still, I don't know why it worked yesterday, and now I need to change the TMPDIR path)
I added this line in the .bashrc:
export TMPDIR="/tmp"
Then run:
soure ~/.bashrc
and now it works.
very interesting. what was TMPDIR set to before?
I'm using WSL2 so I needed to sync it with the Windows temp folder. I had this line in my .bashrc:
export TMPDIR="/mnt/c/Users/julia.s/AppData/Local/Temp"
In fact, if I comment out this line, and run:
echo $TMPDIR
I don't get anything, and everything works.
Also when I assign TMPDIR="/tmp" in the .bashrc file, it still works.
It happens only when it points to "/mnt/c/Users/julia.s/AppData/Local/Temp" folder. (/mnt/c is mount to c drive, in the .bashrc file)
ah, gotcha. It seems like maybe awk itself is using the TMPDIR variable.
If you try reproducing the error, and then modify nvm.sh to call TMPDIR='' command awk instead of just command awk, what happens?
I added these changes on the nvm.sh (I hope that's what you need)

and still, I got the same error:

I tried also to reopen the terminal and got this error:

hmm, that's exactly what i meant, and it didn't fix it :-/
I'm glad you have a workaround, but I'm not sure how I can fix it inside nvm.
Thanks a lot for trying to help!
I'm facing same problem, anyone find a way to solve it
I just found a way to deal with this, in my case was the nameserver that was point to other source. In sudo vim /etc/resolv.conf changed it to 8.8.8.8.
I had the same issue to install node on WSL2. But the error message just say "Version not found"
$ nvm install --lts
Installing latest LTS version.
Version '' (with LTS filter) not found - try `nvm ls-remote --lts` to browse available versions
This command do help to workaround the issue. Thanks!
$ TMPDIR=/tmp nvm install --lts
For me the problem was zscaler. After disabling the zscaler service I was able to install node with npm.