Skip to content

npm on Arch distribution thinks it's on WSL 1 instead of WSL 2 #14341

@thadguidry

Description

@thadguidry

Windows Version

Microsoft Windows [Version 10.0.26200.7840]

WSL Version

2.6.3.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.6.87.2-1

Distro Version

cat /etc/os-release NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling

Other Software

No response

Repro Steps

I begin to make sure that npm is properly installed by running pacman and following the Arch wiki for Node.js and npm install

What was puzzling was that after install, I got the message:

[root@WhitePC portal]# npm -v
WSL 1 is not supported. Please upgrade to WSL 2 or above.
Could not determine Node.js install directory

The following were the commands and sequence:

[root@WhitePC portal]# uname -a
Linux WhitePC 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 GNU/Linux
[root@WhitePC portal]# lsb_release -a
-bash: lsb_release: command not found
[root@WhitePC portal]# cat /etc/os-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
[root@WhitePC portal]# pacman -S nodejs npm
warning: nodejs-25.7.0-1 is up to date -- reinstalling
warning: npm-11.11.0-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Package (2)   Old Version  New Version  Net Change

extra/nodejs  25.7.0-1     25.7.0-1       0.00 MiB
extra/npm     11.11.0-1    11.11.0-1      0.00 MiB

Total Installed Size:  76.87 MiB
Net Upgrade Size:       0.00 MiB

:: Proceed with installation? [Y/n] y
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
:: Processing package changes...
reinstalling nodejs...
reinstalling npm...
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
[root@WhitePC portal]# which npm
-bash: which: command not found
[root@WhitePC portal]# which node
-bash: which: command not found
[root@WhitePC portal]# which nodejs
-bash: which: command not found
[root@WhitePC portal]# npm -v
WSL 1 is not supported. Please upgrade to WSL 2 or above.
Could not determine Node.js install directory
[root@WhitePC portal]# node.exe
-bash: /mnt/c/Program Files/nodejs/node.exe: cannot execute binary file: Exec format error
[root@WhitePC portal]# explorer.exe .
-bash: /mnt/c/WINDOWS/explorer.exe: cannot execute binary file: Exec format error
[root@WhitePC portal]# npm --version
WSL 1 is not supported. Please upgrade to WSL 2 or above.
Could not determine Node.js install directory
[root@WhitePC portal]# echo $basedir

[root@WhitePC portal]# dirname
dirname: missing operand
Try 'dirname --help' for more information.
[root@WhitePC portal]# dirname "$0"
dirname: invalid option -- 'b'
Try 'dirname --help' for more information.
[root@WhitePC portal]# dirname $0
dirname: invalid option -- 'b'
Try 'dirname --help' for more information.
[root@WhitePC portal]# npm --version
WSL 1 is not supported. Please upgrade to WSL 2 or above.
Could not determine Node.js install directory
[root@WhitePC portal]# type wslpath
wslpath is hashed (/usr/sbin/wslpath)
[root@WhitePC portal]# wsl
-bash: wsl: command not found
[root@WhitePC portal]# type wslpath &>/dev/null
[root@WhitePC portal]# uname -r
6.6.87.2-microsoft-standard-WSL2
[root@WhitePC portal]# npm --version
11.6.2
[root@WhitePC portal]# which npm
-bash: which: command not found
[root@WhitePC portal]# npm --version
11.6.2
[root@WhitePC portal]# npm config get prefix
/usr
C:\Users\thadg\AppData\Roaming\npm
-bash: /usr: Is a directory
[root@WhitePC portal]#

Expected Behavior

I expected not to get a WSL 1 is not supported message because I am using WSL 2.

echo "WSL 1 is not supported. Please upgrade to WSL 2 or above."

I expected a better fuller message if the install was indeed bad or something happened to it (which was not my case), such as:

echo "Could not determine Node.js install directory."
echo "You might need to reinstall Node.js or npm or both."

Additionally, I think Arch and Ubuntu have differences in interop with Windows binaries?
In Arch distro for WSL, I would hope that it never, by default, sees my /mnt/c/Program\ Files/nodejs/node.exe that I use for VSCode with Ubuntu as my chosen dev env in VSCode. There are occasions where I do need Arch distro in VSCode and use remote connect to WSL: archlinux for that.

Actual Behavior

What ended up happening was weird indeed.

I left the WSL Arch window open and in another PS did the following:

PS C:\Users\thadg> wsl --install ubuntu
Downloading: Ubuntu
Installing: Ubuntu
Distribution successfully installed. It can be launched via 'wsl.exe -d Ubuntu'
Launching Ubuntu...
Provisioning the new WSL instance Ubuntu
This might take a while...
Create a default Unix user account: thadg
New password:
Retype new password:
passwd: password updated successfully
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

thadg@WhitePC:/mnt/c/Users/thadg$ uname -r
6.6.87.2-microsoft-standard-WSL2
thadg@WhitePC:/mnt/c/Users/thadg$ npm
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term> (in a browser)
npm help npm       more involved overview (in a browser)

All commands:

    access, adduser, audit, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    help-search, init, install, install-ci-test, install-test,
    link, ll, login, logout, ls, org, outdated, owner, pack,
    ping, pkg, prefix, profile, prune, publish, query, rebuild,
    repo, restart, root, run, sbom, search, set, shrinkwrap,
    star, stars, start, stop, team, test, token, undeprecate,
    uninstall, unpublish, unstar, update, version, view, whoami

Specify configs in the ini-formatted file:
    C:\Users\thadg\.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

npm@11.6.2 C:\Program Files\nodejs\node_modules\npm
thadg@WhitePC:/mnt/c/Users/thadg$ npm --version
11.6.2
thadg@WhitePC:/mnt/c/Users/thadg$ uname -r 2>/dev/null
6.6.87.2-microsoft-standard-WSL2

After that Ubuntu distro was installed, I switched back to Arch distro window and continued the last portion from the sequence of commands:

[root@WhitePC portal]# uname -r
6.6.87.2-microsoft-standard-WSL2
[root@WhitePC portal]# npm --version
11.6.2
[root@WhitePC portal]# which npm
-bash: which: command not found
[root@WhitePC portal]# npm --version
11.6.2
[root@WhitePC portal]# npm config get prefix
/usr
C:\Users\thadg\AppData\Roaming\npm
-bash: /usr: Is a directory
[root@WhitePC portal]#

Where it seemed as if the Ubuntu distro install somehow magically made then made Arch distro's npm --version output correctly where it just minutes before was giving the output WSL 1 is not supported. Please upgrade to WSL 2 or above. Could not determine Node.js install directory ?!?! (I'm not joking, this is actually what I witnessed)

Diagnostic Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions