Search code examples
ubuntugithubyarnpkg

How to install yarn from source?


I am trying to install the yarn package manager from source onto my Ubuntu machine.

1) Download yarn tarball from Github Release page

YARN_VERSION=0.17.1
https://github.com/yarnpkg/yarn/releases/download/v${YARN_VERSION}/yarn-v${YARN_VERSION}.tar.gz

2) Extract gzipped tar

tar -xzf yarn-v${YARN_VERSION}.tar.gz

3) Use it

cd ./dist/bin/yarn --version
>> 0.17.10

So far so good.

GOAL: But what is the recommended way to make the yarn executable accessible through /usr/local/bin/yarn --version?

It seems I need to create a symlink. In that case where is the best place to extract the tarball? Is it /usr/local/lib/yarn? How do I create the symlink?


Solution

  • For anyone wanting to build from the bleeding edge, I did the following:

    cd /my/working/directory
    git clone https://github.com/yarnpkg/yarn.git
    cd yarn
    npm install
    gulp build
    

    Then do as z.ky suggests and export PATH=$PATH:/my/working/directory/yarn/bin