ARTIFACTORY: How to Add Packages Using Yarn Instead of Bower

ARTIFACTORY: How to Add Packages Using Yarn Instead of Bower

AuthorFullName__c
Balaji Satish
articleNumber
000004238
ft:sourceType
Salesforce
FirstPublishedDate
2018-08-26T11:46:11Z
lastModifiedDate
2024-03-10T07:47:58Z
VersionNumber
6

Yarn is an alternative to Bower and npm. And although the Bower package manager is still available for use, it has been deprecated by its creators, who are themselves encouraging the use of Yarn as an alternative. To install Yarn on your system, use the method below that’s right for your OS:

CentOS/Fedora/RHEL:

$ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

If Node.js is not installed, it can be installed by using the following command:

$ curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -

Install Yarn:

$ sudo yum install yarn

Debian/Ubuntu:

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

If Node.js is not installed, it can be installed by using one of the two following commands.

for Node.js 8:

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

for Node.js 10:

$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Install Yarn:

$ sudo apt-get update && sudo apt-get install yarn

A speedy, alternative option is to use npm to install Yarn:

$ sudo npm install yarn -g

To display your current Yarn configuration:

$ yarn config list

To  the package from your npm registry:

$ yarn add <package>

Now, to install Bower packages using Yarn, you’ll need to use Bower lookup:

$ bower lookup <package>

To add Bower packages using Yarn:

$ yarn add @bower_components/package@package/package-dist

Example:

$ bower lookup jquery
jquery https://github.com/jquery/jquery-dist.git
yarn add @bower_components/jquery@jquery/jquery-dist


Published: Aug. 26, 2018
Last updated: Mar. 15, 2021

Keywords: Yarn, Bower