Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top