Search code examples
yarnpkgnvm

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


I have nvm:

nvm ls
        v8.11.3
        v8.11.4
->      v11.1.0
default -> 8.11.4 (-> v8.11.4)
node -> stable (-> v11.1.0) (default)
stable -> 11.1 (-> v11.1.0) (default)

I installed yarn with:

sudo apt-get install --no-install-recommends yarn

I also added in .bashrc alias node=nodejs. But when I try yarn install I see:

Yarn requires Node.js 4.0 or higher to be installed.

How can I fix it?


Solution

  • 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.