Skip to content

Latest commit

 

History

History
76 lines (62 loc) · 1.87 KB

NODEJS-SETUP.md

File metadata and controls

76 lines (62 loc) · 1.87 KB

Node.js Development Setup

We'll install a recent version of Node.js using nvm. We'll also install Yarn 1.x package manager alongside the standard npm CLI.

  1. Install nvm using Git:

    cd ~/
    git clone https://github.com/nvm-sh/nvm.git .nvm
    cd ~/.nvm
    git checkout v0.39.5
  2. Add the following at the end of your ~/.bashrc:

    ###
    # nvm
    # source: https://github.com/nvm-sh/nvm#git-install
    ###
    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
    
    ###
    # yarn global symlinks directory (yarn global bin)
    # see https://classic.yarnpkg.com/en/docs/cli/global
    ###
    # export PATH="$(yarn global bin):$PATH"
    # to speed things up, inline the path directly:
    export PATH="$HOME/.yarn/bin:$PATH"
  3. Restart your terminal. Verify nvm works (should print something like 0.39.5):

    nvm -v
  4. Install the latest Node.js 20:

    nvm install 20.*
  5. Verify Node.js is installed and active (should print something like v20.6.1):

    node -v
  6. Upgrade bundled npm and install yarn:

    npm --global install npm yarn
  7. Check the installed versions:

    npm -v
    yarn -v
  8. Set yarn prefix for global bins (it's the default, but to be future-proof):

    yarn config set prefix ~/.yarn
  9. Install some useful global packages using Yarn:

    yarn global add node-gyp nodemon sort-package-json doctoc
  10. Verify that Yarn global packages binaries are on your PATH (should print 3.0.1):

    nodemon -v

That's all!