Skip to content

Instantly share code, notes, and snippets.

@micahgodbolt
Last active December 22, 2022 09:37
Show Gist options
  • Save micahgodbolt/8b9a338c8bab7bc147975646ea20826c to your computer and use it in GitHub Desktop.
Save micahgodbolt/8b9a338c8bab7bc147975646ea20826c to your computer and use it in GitHub Desktop.
WSL install Node

The apt-get version of node is incredibly old, and installing a new copy is a bit of a runaround.

So here's how you can use NVM to quickly get a fresh copy of Node on your new Bash on Windows install

$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
// restart bash
$ nvm install --lts

Once you've done that you'll get a nice:

$ node --version
$ v12.18.3
@Lawrencemm
Copy link

Thanks for this.

@ogrotten
Copy link

A "can't miss" tip. Thanks.

@stateofjermaine
Copy link

Wow, this is amazing. Thanks!

@jozsefm
Copy link

jozsefm commented May 28, 2018

I had some trouble on a fresh install of Windows 10 Pro using this script, but found this instruction by NodeSource to be working well, installing the latest nodejs (v10 currently). It's also just two commands:
https://github.com/nodesource/distributions#debinstall

@jcklpe
Copy link

jcklpe commented Jul 18, 2018

Why does the bashrc need to be touched? I'm a designer learning to code so I'm kind of ignorant of this stuff and want to better understand what I'm actually doing with it.

@aizkhaj
Copy link

aizkhaj commented Oct 20, 2018

Thanks for this quick tip! I know it's referring to bash, but will I essentially just need to | zsh if I want to use zsh instead of bash?

@jcklpe
Copy link

jcklpe commented Nov 17, 2018

@devkabiir Ah okay, that makes sense, but if I use zsh should I touch .zshrc instead?

Also as per @aizkhaj 's question

@gabefair
Copy link

Other node versions can be found here: https://github.com/nodesource/distributions#debinstall

@meekray
Copy link

meekray commented Jan 15, 2019

Nice!

@bcawrse
Copy link

bcawrse commented Jan 28, 2019

@devkabiir Ah okay, that makes sense, but if I use zsh should I touch .zshrc instead?

Also as per @aizkhaj 's question

I run zsh. Installing nvm with curl | bash updated my .bashrc. I just copy / pasted the 3 lines added at the bottom of .bashrc to .zshrc and ran exec zsh to restart my shell and it all worked fine. The lines should be easy to identify.

@cvladan
Copy link

cvladan commented Mar 30, 2019

I had some trouble on a fresh install of Windows 10 Pro using this script, but found this instruction by NodeSource to be working well, installing the latest nodejs (v10 currently). It's also just two commands:
https://github.com/nodesource/distributions#debinstall

Thanks for nodesource method!

@burkeholland
Copy link

Micah! Thank you so much for this! I could not for the life of me figure out why things like npx were just missing. ❤❤❤❤❤

@micahgodbolt
Copy link
Author

Thanks everyone for all the comments. Sorry that GitHub never sends me notifications of Gist comments.

@T0miii
Copy link

T0miii commented May 24, 2019

thx quick and easy.

@nimendra
Copy link

thanks!

@OctupleSakura
Copy link

Thanks for this!

@leicht-io
Copy link

Thanks!

@SheryConcepts
Copy link

thanks pal
worked for me : -D

@tuhin47
Copy link

tuhin47 commented Oct 20, 2020

sometimes restart doesn't work. Try: source ~/.bashrc .it works for me.

@sshivaji
Copy link

Or you can run
exec "$SHELL" to do the source and reinit of shell

@YasinKuralay
Copy link

Thanks, worked like a charm!

@firmanramdhani
Copy link

Thanks! worked for me.

@tlaughlan
Copy link

This rules. Thanks.

@aitahtman
Copy link

thanks for this 👍

@lukelovekin
Copy link

Awesome, thanks!!

@Allow-tap
Copy link

great gist :) 💯

@AkshayThakur1995
Copy link

Thankyou :)

@ChristianRich1
Copy link

After a bunch of failed attempts I ended up here. This approach totally works.

For the latest curl and installation details:
https://github.com/nvm-sh/nvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment