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

Open
saraf opened this issue Jun 11, 2018 · 7 comments
Open

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

saraf opened this issue Jun 11, 2018 · 7 comments
Labels

Comments

@saraf
Copy link

@saraf 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

This comment has been minimized.

Copy link

@lemcii 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

This comment has been minimized.

Copy link

@jamieweavis jamieweavis commented Jul 23, 2018

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

This comment has been minimized.

Copy link

@PhEEP 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 label Mar 27, 2019
@virgilwashere

This comment has been minimized.

Copy link

@virgilwashere virgilwashere commented Jun 18, 2019

💻 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

@AAv-Soft

This comment has been minimized.

Copy link

@AAv-Soft AAv-Soft commented Jan 12, 2020

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 was marked as resolved.

Copy link

@gengjiawen gengjiawen commented Jan 29, 2020

image

Mirror looks like not working through.

@shadowspawn

This comment was marked as resolved.

Copy link
Collaborator

@shadowspawn shadowspawn commented Jan 29, 2020

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.