Reputation: 9596
In my project I've installed Bower components without the save option. Now, I would like update to bower.json
.
How can I update bower.json with installed packages?
Upvotes: 131
Views: 91870
Reputation: 11067
Before doing anything, rename your bower.json file in bower2.json, for example.
Then you can do a:
bower init
(it automatically creates a bower.json file).
Note that all questions should be pre-filled with your current configuration.
When it will ask you:
set currently installed components as dependencies?
say "yes".
You now have all your dependencies in the new bower.json file (and you can check if everything is right with the old bower2.json file).
Upvotes: 135
Reputation: 2064
If there aren't that many Bower packages you have installed, try writing bower install [package_name] --save
. This will just update your bower.json file.
Upvotes: 2
Reputation: 17551
You can use bower-check-updates (you need an installed Node.js on your machine):
bower-check-updates
is a utility that automatically adjusts a bower.json file with the latest version of all dependencies.
bower-check-updates is a fork of npm-check-updates, so it's all the same, but it updates file bower.json, instead of file package.json.
npm install -g bower-check-updates
bower-check-updates -u
bower install
This will install bower-check-updates
globally, so you can launch it from anywhere.
P.S.: For more information about npm-check-updates, please see this topic
Upvotes: 28
Reputation: 1847
Just list your dependencies:
bower list
Then you should run all install commands with parameter '--save' like this:
bower install bootstrap --save
It's a hard work, but if you have a thousand dependencies, you could create a script to automate the task.
Upvotes: 146
Reputation: 10705
A bit arduous way is to run bower list
, look for packages labeled extraneous and add those manually to the dependencies in the bower.json file.
If there are a lot of extraneous packages, it might be easier to workaround this by running bower init
and answering Yes to "set currently installed components as dependencies?". This will take your current bower.json file, read it and then create new one using information from the old one. So in an ideal case you will have the same file just with extraneous packages added.
Warning: Firstly, there might be something lost in the process (e.g., devDependecies
). Secondly, in the last version of Bower (v1.2.7) this will not preserve current packages information! I feel it is a bug. However you can save the old file and (manually) merge it with the generated one.
Also, you should ask for an option or something by opening a Bower issue as this would be welcomed by many developers.
Upvotes: 35
Reputation: 241
After bower-check-updates -u
you must run bower install
instead of npm install
Upvotes: 0