Yarn global command not working

后端 未结 9 1935
孤独总比滥情好
孤独总比滥情好 2020-12-12 13:07

I\'m working with Yarn v0.16.1. If I understand correctly (according to the documentation), yarn global add should be the equivalent of np

9条回答
  •  误落风尘
    2020-12-12 13:48

    Update Dec 2018

    Just updating the path didn't work for me. I had to also set the yarn prefix.

    • Ubuntu 18.04.1 LTS (bionic)
    • yarn 1.12.3
    • npm v3.5.2
    • node v8.10.0
    • zsh 5.4.2

    Steps

    1. Confirm your global bin path

      yarn global bin
      

    I got: /home/username/.yarn/bin

    1. set yarn prefix:

      make sure your yarn prefix is the parent directory of your bin directory. You can confirm by running

      yarn config get prefix
      

      when I ran this, my prefix was empty, so I set it:

      yarn config set prefix ~/.yarn
      
    2. add the following to ~/.bash_profile or ~/.bashrc

      export PATH="$PATH:`yarn global bin`"
      

      for zsh users, be sure to add this line to ~/.zshrc

    3. restart your shell or start a new one

      bash -l or zsh

提交回复
热议问题