Skip to content

Instantly share code, notes, and snippets.

@tkrisztian95
Forked from micahgodbolt/wsl_install_node.md
Last active September 22, 2020 19:18
Show Gist options
  • Save tkrisztian95/4ebbb1a32f4ee1eeb0047be0fa50b2d3 to your computer and use it in GitHub Desktop.
Save tkrisztian95/4ebbb1a32f4ee1eeb0047be0fa50b2d3 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

//switch to root
$ sudo su

//get NVM
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
$ nvm --version
0.35.3

// Close and reopen your terminal to start using nvm or run the following to use it now:
$ export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

//python3-distutils is a required dep see more at [link](https://github.com/nodejs/node/issues/30189)
$ apt install python3-distutils -y

// to install latest version use 'node' instead '--lts'
$ nvm install --lts

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

$ node --version
$ v12.18.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment