Manage Node with NVM and Yarn in Arch Linux Jan 24th 2021 Words: 169

nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.

Install NVM

1
sudo pacman -S nvm

Install zsh plugin

1
git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm

Then add zsh-nvm to plugin list in ./zshrc

Install node

1
nvm install --lts

This will compile (unfortunately) and install the latest LTS

Install yarn

1
npm install -g yarn

Do NOT install the yarn from package manager (pacman), it has the node dependency that mess with NVM.

Use Yarn in project

Official guide: pre-project install

1
2
3
4
yarn set version latest

# use proxy if necessary
yarn set version latest --proxy=http://localhost:1081

Set proxy for the working project by edit ./yarnrc

Add following lines:

1
2
httpProxy: "http://localhost:1081"                                                                                                                              
httpsProxy: "http://localhost:1081"