How to upgrade yarn version using terminal?

后端 未结 14 2228
一生所求
一生所求 2021-01-30 05:03

How should yarn be upgraded to the latest version?

相关标签:
14条回答
  • 2021-01-30 05:09

    yarn policies set-version

    will download the latest stable release

    Referenced yarn docs https://yarnpkg.com/lang/en/docs/cli/policies/#toc-policies-set-version

    0 讨论(0)
  • 2021-01-30 05:10

    I tried all of the above solutions in Jenkins pipeline which needs the latest yarn. Finally, this worked for me.

    1. Run yarn policies set-version in the git repo
    2. This will generate .yarn/releases/yarn-X.X.X.js file and .yarnrc file. Push both of these files in the Git repo.
    3. Now build and all the yarn commands will use the yarn-X.X.X version.

    Note: This is helpful when you don't have root access to npm install -g yarn.

    0 讨论(0)
  • 2021-01-30 05:13

    Not remembering how i've installed yarn the command that worked for me was:

    yarn policies set-version

    This command updates the current yarn version to the latest stable.

    From the documentation:

    Note that this command also is the preferred way to upgrade Yarn - it will work no matter how you originally installed it, which might sometimes prove difficult to figure out otherwise.

    Reference

    0 讨论(0)
  • 2021-01-30 05:16

    I had an outdated symlink that was preventing me from accessing the proper bin. I had also recently gone through a node upgrade which means a lot of my newer bins were available in a different folder with what i think was a lower priority

    Here is what worked for me:

    yarn -v 
    > 1.15.2
    
    which yarn
    > /Users/lfender/.yarn/bin/yarn 
    
    rm -rf /Users/lfender/.yarn/bin/yarn
    npm uninstall --global yarn; npm install --global yarn
    
    > + yarn@1.16.0
    > added 1 package in 0.179s
    
    which yarn
    > /Users/lfender/.nvm/versions/node/v12.2.0/bin/yarn
    
    yarn -v
    > 1.16.0
    

    If you are not using NVM, the location of your bin installs are likely to be unique to your system

    From there, I've switched to doing yarn policies set-version as outlined here https://stackoverflow.com/a/55278430/1426788 to define my yarn version at the repo level

    0 讨论(0)
  • 2021-01-30 05:16

    yarn policies set-version

    Use the above command in powershell to upgrade your current yarn version to Latest.It will download the latest yarn release

    0 讨论(0)
  • 2021-01-30 05:19

    For Windows users

    I usually upgrade Yarn with Chocolatey.

    choco upgrade yarn
    
    0 讨论(0)
提交回复
热议问题