Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make requirements.txt-like file with bower?

I've started working with bower, and it seems really helpful. I come from a python background, and so I'm used to having virtualenv and requirements.txt.

Since I'd rather not store all my dependencies in source control if I can help it, I was wondering, how can I create a file like requirements.txt with bower?

like image 298
NT3RP Avatar asked Jan 14 '23 11:01

NT3RP


1 Answers

After poking around a bit more, I have the solution.

bower uses a file called bower.json (formerly component.json) which is similar to a Gemfile or requirements.txt.

It can be created manually, and will look something like this...

{
    "name": "<app name, defaults co current folder name>",
    "version": "0.0.0",
    "dependencies": {
        "backbone": "~0.9.10",
        "underscore": "~1.4.3"
    }
}

However, the piece that I was missing was to include the --save flag when installing packages in bower:

bower install <package_name> --save

Unfortunately, I do not believe there is a way to set this behaviour by default using the .bowerrc file.

As an added tidbit, once you have a bower.json file, installing your dependencies is as simple as running bower install.

like image 200
NT3RP Avatar answered Jan 21 '23 06:01

NT3RP