Skip to content

Instantly share code, notes, and snippets.

@suvel-the-dev
Created May 24, 2022 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suvel-the-dev/367798ca44e74428c2919b486c4533ab to your computer and use it in GitHub Desktop.
Save suvel-the-dev/367798ca44e74428c2919b486c4533ab to your computer and use it in GitHub Desktop.
instruction to install node and npm successfully in WSL

Setup a node.js env in WSL

I was trying to install nodejs in WSL for Emulating a server enviourment for creating and test a code before deploying into server. I was able to install the node successfully, but had issue with using npm. After a lot searching I was able to fix the issue by using nvm, here I am sharing the step for the same hope it helps.

I had also uninstalled the nodejs before proceding the nvm installation, here are commands for to perform the same:

  1. removing nodejs

    sudo get-apt remove nodejs
    
  2. update the pakages

    sudo apt-get update
    
  3. Install NVM

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
    
  4. Reload shell

    source ~/.bashrc
    
  5. Install the required node version

    nvm install v<version number>
    

Reference

  1. Installing Node.js with nvm to Linux & macOS & WSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment