nvm with yarn Yarn requires Node.js 4.0 or higher to be installed

First uninstall the nodejs package:

sudo apt remove nodejs

Ubuntu 16.04 contains a version of Node.js in its default repositories that can be used to easily provide a consistent experience across multiple systems. At the time of writing, the version in the repositories is v4.2.6. This will not be the latest version, but it should be quite stable and sufficient for quick experimentation with the language.

In order to get this version, we just have to use the apt package manager. We should refresh our local package index first, and then install from the repositories:

sudo apt-get update
sudo apt-get install nodejs

If the package in the repositories suits your needs, this is all you need to do to get set up with Node.js. In most cases, you’ll also want to also install npm, which is the Node.js package manager. You can do this by typing:

sudo apt-get install npm

This will allow you to easily install modules and packages to use with Node.js.

Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejs instead of node. Keep this in mind as you are running software.

To check which version of Node.js you have installed after these initial steps, type:

nodejs -v

Screenshot for nodejs version


I had the same issue. by putting nvm path above yarn path didn't solve the issue then I looked up for a solution in man page and solve the issue by setting default node version on a shell.

Current lts version is v14.17.6 so i install it use it and set default node version on a shell.

nvm install --lts
nvm use --lts
nvm alias default <version>

Additional you can set always default to the latest available node version on a shell by running below command.

nvm alias node <version>

This gist helped on this problem.

Run the following commands

echo "==> Installing Yarn package manager"
rm -rf ~/.yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
# Yarn configurations
export PATH="$HOME/.yarn/bin:$PATH"
yarn config set prefix ~/.yarn -g

And add the following in ~/.bashrc

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

It should then work properly without the warning after restarting the shell.


I just want to mention that my configuration file looked something like that

export PATH=$PATH:`yarn global bin`

#NVM INITIALIZATION STUFF

(yarn docs recommended $PATH)

the export was before my nvm initialization. Which meant node was not available during the runtime of that line. So I just switched my configuration file to be

#NVM INITIALIZATION STUFF

export PATH=$PATH:`yarn global bin`

Tags:

Nvm

Yarnpkg