Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install Bower packages with Yarn?

From the project's README:

Multiple Registries: Install any package from either npm or Bower and keep your package workflow the same.

I'm assuming that means that I can install my Bower packages (listed in my project's bower.json) with Yarn. If this is the case, how would I go about doing that?

I'm not seeing any mention of Bower or using separate registries in the documentation. However, I do see the Bower registry listed in the source.

like image 934
Douglas Ludlow Avatar asked Oct 12 '16 15:10

Douglas Ludlow


People also ask

How do I install bower components?

You can also create a bower. json file and define multiple packages name with or without version. Navigate to your project folder directory and run the command “bower install”. It will download and install all the packages in your bower_components folder.

How do you add bower components to a project?

To add a new Bower package to your project you use the install command. This should be passed the name of the package you wish to install. As well as using the package name, you can also install a package by specifying one of the following: A Git endpoint such as git://github.com/components/jquery.git.

Can yarn install npm packages?

Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.


2 Answers

UPDATE 11/4/16: Yarn decided to remove support for Bower. See the Github pull request and Bower's blog. =(

ORIGINAL: Bower just posted a blog post about this topic. They seem excited about it, but point out that there are currently unresolved issues:

Important note: As it stands right now there still seem to be some issues regarding Bower support. We are however confident that with the help of the community, these issues will be solved quickly as Yarn steps towards 1.0 in upcoming months.

He also refers to a pull request for a bower patch.

When I ran yarn, it deleted my bower_components folder (GitHub ticket here)! I really like yarn though, can't wait for the bower bugs to get resolved.

like image 84
cs01 Avatar answered Sep 18 '22 18:09

cs01


If you add the following to package.json, bower install will be called and it works. It is a workaround though:

"scripts": {
    "postinstall": "bower install"
}
like image 23
Omnisite Avatar answered Sep 20 '22 18:09

Omnisite