How to update bower.json with installed packages?

后端 未结 6 1102
遇见更好的自我
遇见更好的自我 2021-01-29 22:28

In my project I\'ve installed bower components without save option. Now, I would like update to bower.json?

How can I update b

6条回答
  •  梦如初夏
    2021-01-29 23:28

    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.

    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, 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 info! 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.

提交回复
热议问题