Skip to content

Instantly share code, notes, and snippets.

@namgivu
Last active October 14, 2020 00:53
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 namgivu/bbb2854ad889ff21f6f49d72833a4139 to your computer and use it in GitHub Desktop.
Save namgivu/bbb2854ad889ff21f6f49d72833a4139 to your computer and use it in GitHub Desktop.

install nvm

ref. https://itnext.io/nvm-the-easiest-way-to-switch-node-js-environments-on-your-machine-in-a-flash-17babb7d5f1b ref. https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/

cd ~
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash  # get latest version at https://github.com/nvm-sh/nvm#install--update-script

: reload your bash prompt

nvm --version # should print the version as a proof of successful installation

install nodejs

nvm ls-remote       # list all versions

nvm ls              # list installed versions

nvm install 8.12.0  # install a version
nvm install node    # install latest

switch nodejs version

nvm use 8.12.0            # use this version for local folder
nvm use node              # use latest version for local folder

nvm alias default 8.12.0  # set this version as default version aka the **global** node version

view current status

nvm current       # view current version
nvm which 8.12.0  # view path of the binary nodejs
nvm which current # view path of current nodejs version

misc

nvm alias awesome-version 8.9.4 # name/make-alias for this specific version
nvm unalias awesome-version     # remove the alias

nvm run 8.12.0 --version #TODO
nvm exec 8.12.0 node --version #TODO

install yarn

Very often, nodejs engineer will use yarn to install nodejs packages ref. htoc-option-2-install-yarn-using-npm

npm install -g yarn

npm install --global yarn
npm i -g yarn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment