Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n now works on windows 10 (using windows subsystem for linux) #511

Closed
saraf opened this issue Jun 11, 2018 · 13 comments
Closed

n now works on windows 10 (using windows subsystem for linux) #511

saraf opened this issue Jun 11, 2018 · 13 comments
Assignees
Labels
docs Changes to README or other documentation

Comments

@saraf
Copy link

saraf commented Jun 11, 2018

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/.config

IMPORTANT NOTE:

  • change the name in the path when using the chown command 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.0

Tried installing other node versions, using

sudo n install latest

And got:

$ node --version
v10.4.0
$ npm --version
6.1.0
@lemcii
Copy link

lemcii commented Jul 3, 2018

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.

@jamieweavis
Copy link

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

@PhEEP
Copy link

PhEEP commented Jul 25, 2018

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! 🤷‍♂️

@shadowspawn shadowspawn added the docs Changes to README or other documentation label Mar 27, 2019
@virgilwashere
Copy link

💻 Windows version

Microsoft Windows [Version 10.0.18362.175]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Virgil>

⭕️ WSL Distro

$ lsb_release -ds
Ubuntu 18.04.2 LTS
$ uname -rom
4.4.0-18362-Microsoft x86_64 GNU/Linux

⚙️ Version of 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

binary locations

$ 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

📋 How I installed N

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

@AlexVirlan
Copy link

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/.config

IMPORTANT NOTE:

  • change the name in the path when using the chown command 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.0

Tried installing other node versions, using

sudo n install latest

And 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

@gengjiawen

This comment has been minimized.

@shadowspawn

This comment has been minimized.

@jonathan-annett
Copy link

jonathan-annett commented Aug 11, 2020

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

@shadowspawn
Copy link
Collaborator

That looks like "normal" @jonathan-annett , exciting!

@shadowspawn
Copy link
Collaborator

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": nvm-sh/nvm#2391

@shadowspawn
Copy link
Collaborator

I finally gave this a try myself, and it Just Worked using curl to get down n and using it to install node and npm.

I did not need to fix the ownership on the ~/.config directory. Is this no longer a problem with more recent versions of WSL setup?

@shadowspawn
Copy link
Collaborator

First cut at wording for README.

Supported Platforms

n is supported on macOS, Linux, including with Windows Subsystem for Linux, and various other unix-like systems.
It is written as a BASH script but does not require you to use BASH as your command shell.

n does not work in native shells on Microsoft Windows (like PowerShell), or Git for Windows BASH, or with the Cygwin DLL.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Jun 6, 2021

Released updated README in v7.3.0, at last. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Changes to README or other documentation
Projects
None yet
Development

No branches or pull requests

9 participants