If enough people find that this works for them, the docs / README.md could be changed to reflect this.
_Windows 10 Home, Version 10.0.17134 Build 17134_
_n --version output: 2.1.11_
Start up windows subsystem for linux bash prompt by typing Win key followed by wsl
Then, install using the following sequence:
sudo apt-get install nodejs-legacy
sudo apt-get install npm
sudo npm install -g n
sudo n lts
sudo npm install npm@lts -g
sudo chown -R $USER:$(id -gn $USER) /home/aal/.config
IMPORTANT NOTE:
chown command above to reflect your home directory in WSL.After restarting the WSL bash window:
$ node --version
v8.11.2
$ npm --version
5.6.0
Tried installing other node versions, using
sudo n install latest
And got:
$ node --version
v10.4.0
$ npm --version
6.1.0
Worked for me, I used n-install at first, but that wouldn't work being directly called through bash.exe. However, the method you've suggested works just fine.
Tried installing other node versions, using
sudo n install latest
Should be sudo n latest.
I can confirm that this is working on the latest version of Windows 10 Pro! ๐
_Windows 10 Pro version 1803 build 17134.165_
Anyone coming here who installed n like this:
curl -L https://git.io/n-install | bash
On the off chance that you have the same problems that I did where the node version installed by n was not the one being referenced, I have a little tidbit for you. When I would n 9.6.1 it would fetch and install 9.6.1, but would then say that 8.11.x was installed. I think this has something to do with how node is linked or referenced or something.
If which -a node returns multiple directories, rm all of them except the one with n in the path. This worked for me, whether it's intended or not.
Now, when I which -a node I only see the path to node as installed by n.
Hope this helps more than it confuses! ๐คทโโ๏ธ
Microsoft Windows [Version 10.0.18362.175]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Virgil>
$ lsb_release -ds
Ubuntu 18.04.2 LTS
$ uname -rom
4.4.0-18362-Microsoft x86_64 GNU/Linux
n$ n --version
4.1.0
Or the more extended versions:
$ has n node npm nvm npx yarn
โ n 4.1.0
โ node 10.16.0
โ npm 6.9.0
โ nvm
โ npx 6.9.0
โ yarn 1.16.0
โ git 2.21.0
$ n latest
$ has n node npm nvm npx yarn
โ n 4.1.0
โ node 12.4.0
โ npm 6.9.0
โ nvm
โ npx 6.9.0
โ yarn 1.16.0
โ git 2.21.0
$ type -p n node npm npx yarn
/home/virgil/.local/n/bin/n
/home/virgil/.local/n/bin/node
/home/virgil/.local/n/bin/npm
/home/virgil/.local/n/bin/npx
/usr/bin/yarn
๐ฅ [has] is from here
via n-install
$ nvm unload
$ curl -#L https://git.io/n-install | N_PREFIX=$HOME/.local/n bash -s -- -y lts 0.11
n-install output
######################################################################## 100.0%
-- Cloning https://github.com/tj/n to '/home/virgil/.local/n/n/.repo'...
-- Running local n installation to '/home/virgil/.local/n/bin'...
-- Shell initialization file '/home/virgil/.bashrc' updated.
-- Installing helper scripts in '/home/virgil/.local/n/bin'...
-- Installing the requested Node.js version(s)...
1 of 2: lts...
install : node-v10.16.0
mkdir : /home/virgil/.local/n/n/versions/node/10.16.0
fetch : https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.gz
######################################################################## 100.0%
installed : v10.16.0
2 of 2: 0.11...
install : node-v0.11.16
mkdir : /home/virgil/.local/n/n/versions/node/0.11.16
fetch : https://nodejs.org/dist/v0.11.16/node-v0.11.16-linux-x64.tar.gz
######################################################################## 100.0%
installed : v0.11.16
=== n successfully installed.
The active Node.js version is: v10.16.0
Run `n -h` for help.
To update n later, run `n-update`.
To uninstall, run `n-uninstall`.
IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. /home/virgil/.bashrc`
before using n and Node.js.
===
And the whole reason I replied to this issue:
sudo chown -R $USER:$(id -gn $USER) /home/aal/.config
sudo chown -R $USER:$(id -gn $USER) ${XDG_CONFIG_HOME:-"$HOME/.config"}
๐ค If you are going to bother with id -gn instead of $USER:, use the correct environment variables.
Virgil
n now works on Windows 10 (Windows Subsystem For Linux):
If enough people find that this works for them, the docs / README.md could be changed to reflect this.
Windows version
_Windows 10 Home, Version 10.0.17134 Build 17134_
Version of N
_n --version output: 2.1.11_
How I installed N
Start up windows subsystem for linux bash prompt by typing Win key followed by
wsl
Then, install using the following sequence:sudo apt-get install nodejs-legacy sudo apt-get install npm sudo npm install -g n sudo n lts sudo npm install npm@lts -g sudo chown -R $USER:$(id -gn $USER) /home/aal/.configIMPORTANT NOTE:
- change the name in the path when using the
chowncommand above to reflect your home directory in WSL.- Then, exit the shell and start it up again.
After restarting the WSL bash window:
$ node --version v8.11.2 $ npm --version 5.6.0Tried installing other node versions, using
sudo n install latestAnd got:
$ node --version v10.4.0 $ npm --version 6.1.0
Dude, you are awesome!
This topic should be pinned in the readme of the project!
"Petition" to do that :D

Mirror looks like not working through.
@gengjiawen
Check the documentation for sudo. Typically environment variables are not preserved for the sudo context unless you specify an option.
e.g.
The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables.
So you would run:
sudo -E n latest
Here's how i did it, to avoid having to use sudo for either npm or n:
sudo apt-get install npm
sudo mkdir -p /usr/local/n
sudo chown -R $(whoami) /usr/local/n
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
npm install -g n
n lts
That looks like "normal" @jonathan-annett , exciting!
For interest in changes which might be required to support more than WSL, PR for nvm to "Make it work on Windows with WSL, MSYS, Cygwin": https://github.com/nvm-sh/nvm/pull/2391
Most helpful comment
Anyone coming here who installed
nlike this:On the off chance that you have the same problems that I did where the node version installed by
nwas not the one being referenced, I have a little tidbit for you. When I wouldn 9.6.1it would fetch and install9.6.1, but would then say that8.11.xwas installed. I think this has something to do with how node is linked or referenced or something.If
which -a nodereturns multiple directories,rmall of them except the one withnin the path. This worked for me, whether it's intended or not.Now, when I
which -a nodeI only see the path to node as installed byn.Hope this helps more than it confuses! ๐คทโโ๏ธ