Skip to content

Instantly share code, notes, and snippets.

@x3rAx
Last active August 4, 2022 07:50
Show Gist options
  • Save x3rAx/14f6f1f093a946c334ca9f89c69f7fa2 to your computer and use it in GitHub Desktop.
Save x3rAx/14f6f1f093a946c334ca9f89c69f7fa2 to your computer and use it in GitHub Desktop.
n-install

Install n the node package manager

Prerequisites

The following tools must be installed

  • git
  • curl
  • make

Installation

(see instructions for WSL below)

Test if install prerequisites are met:

curl -sL https://git.io/n-install | N_PREFIX=~/.local/opt/n bash -s -- -t

Install automatically to a specific prefix:

curl -sL https://git.io/n-install | N_PREFIX=~/.local/opt/n bash -s -- -y

Install automatically to a specific prefix without modifying .bashrc (or others):

curl -sL https://git.io/n-install | N_PREFIX=~/.local/opt/n bash -s -- -y -n

Add the following line (or your shell's equivalent) to your initialization file:

export N_PREFIX="$HOME/.local/opt/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"  # Added by n-install (see http://git.io/n-install-repo)

WSL

Remove Windows version of Node from $PATH :

export PATH="$(echo $PATH | awk -v RS=':' -v ORS='' '/\/c\// {next} {print sep $0; sep = ":"}')"

Now install n without editing .bashrc:

curl -sL https://git.io/n-install | N_PREFIX=~/.local/opt/n bash -s -- -y -n

Then add the n binary path at the beginning of the $PATH in your .bashrc

export N_PREFIX="$HOME/.local/opt/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH="$N_PREFIX/bin:$PATH"  # Added by n-install (see http://git.io/n-install-repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment