Installing Node.js / npm under Ubuntu with nvm (with yarn)
I recommend install Node.js using nvm. This way you can have multiple Node versions in your
~/.nvm. You also won't need to install global packages with
DigitalOcean has a HOWTO for installing nvm on Ubuntu (, , ) that I recommend.
nodejs, but with nvm you no longer want to have that package installed through
You can install yarn while skipping dependencies like this:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install --no-install-recommends yarn
If yarn stops updating, the imported key has expired and you need to re-run the line with
sudo apt remove nodejs
Check if you want to remove any custom package sources for Node.js in your
In case you see an error like:
Yarn requires Node.js 4.0 or higher to be installed.
command -v "node" returns a path and you load NVM before Yarn. This could look like this:
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 # Load global yarn binaries export PATH="$PATH:$(yarn global bin)"
If you want to switch the Node version automatically with a
cd you can use
Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.