Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/creationix/nvm/v0.33.6/install.sh | bash
// restart bash
$ nvm install node

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

$ node --version
$ v7.4.0
@Lawrencemm

This comment has been minimized.

Copy link

Lawrencemm commented Nov 24, 2017

Thanks for this.

@ogrotten

This comment has been minimized.

Copy link

ogrotten commented Feb 18, 2018

A "can't miss" tip. Thanks.

@stateofjermaine

This comment has been minimized.

Copy link

stateofjermaine commented May 4, 2018

Wow, this is amazing. Thanks!

@jozsefm

This comment has been minimized.

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

This comment has been minimized.

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.

@devkabiir

This comment has been minimized.

Copy link

devkabiir commented Aug 3, 2018

@thedonquixotic, You need .bashrc because nvm loads itself on bash startup, and in order to do so it needs to write some line to that file. It also enables auto completion of nvm on your terminal

@aizkhaj

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

gabefair commented Nov 19, 2018

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

@meekray

This comment has been minimized.

Copy link

meekray commented Jan 15, 2019

Nice!

@bcawrse

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

burkeholland commented May 7, 2019

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

This comment has been minimized.

Copy link
Owner Author

micahgodbolt commented May 7, 2019

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

@T0miii

This comment has been minimized.

Copy link

T0miii commented May 24, 2019

thx quick and easy.

@nimendra

This comment has been minimized.

Copy link

nimendra commented Jun 16, 2019

thanks!

@OctupleSakura

This comment has been minimized.

Copy link

OctupleSakura commented Nov 18, 2019

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.