Installing Node.js for Linux & macOS with nvm
A quick guide on how to setup Node.js development environment.
Previous versions of these install instructions had been tested with:
The reason for using nvm instead of other install types is mainly in how easy it is to have multiple versions of Node.js (if needed) without too much of extra complexity. Sometimes applications might require a certain version of Node.js to work, so having the flexibility of using specific versions can save a lot of time from you.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
~/.nvm
and adds the source line to your profile (~/.bash_profile
, ~/.zshrc,
~/.profile,
or ~/.bashrc
). (You might want/need to add the source loading line by yourself, if the automated install tool does not add it for you.)
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
source ~/.bashrc
command -v nvm
nvm ls
nvm install v8.9.4
nvm install v9.6.1
nvm alias default v8.9.4
(if you work with production quality projects)nvm alias default v9.6.1
(if you want to use the latest features of Node.js)It is also possible to select what Node.js version is used per project basis, by running nvm use v9.6.1
(or another version number) on the directory where the individual project is located. One way to do that is to create small Bash shell script for enabling the right environment when needed, so you would not have to remember what exact version was needed.
Now you have it.
After previous steps, now you should have a working Node.js installation with the ability to install new npm packages to your computer.
npm install -g yo
You can find a lot of other packages from the npm website. Have a good time with the tools.
If you already have previous version of Node.js installed with nvm, you can upgrade to a different version with these steps.
v8._._
).
nvm reinstall-packages v8.9.3
npm ls -g --depth=0.
npm outdated -g --depth=0.
npm update -g
nvm ls
nvm uninstall v8.9.3