【问题标题】:How to configure Bower API programmatically in Nodejs如何在 Nodejs 中以编程方式配置 Bower API
【发布时间】:2016-12-01 06:31:21
【问题描述】:

文件:bower.json

bower.json 文件包含依赖、解析和覆盖对象。

"name": "XYZ",
"version": "1.0.0",
"dependencies": {
    "angular": "1.5.9",
    "angular-resource": "1.5.9",
    "angular-sanitize": "1.5.9",
    "angular-animate": "1.5.9",
    "angular-ui-router": "0.3.2",
    "ui-router-extras": "0.1.3",
    "jquery": "3.1.1",
    "moment": "2.17.0",
    "lodash": "4.17.2"
}, 
"resolutions": {
    "angular": "1.5.9",
    "angular-animate": "
    "slickgrid": "1.5.0",        
    "lodash": "4.17.2",
    "jquery": "3.1.1",
    "underscore": "^1.8.0"
},
"overrides": {
    "angular": {
         "dependencies": {
              "jquery": "*"
          }
    },
    "lodash": {
          "dependencies": {
               "underscore": "*"
          }
     }
}

NodeJS 代码

var bowerDependencies = [ 'angular@1.5.9',
  'angular-resource@1.5.9',
  'angular-sanitize@1.5.9',
  'angular-animate@1.5.9',
  'angular-ui-router@0.3.2',
  'ui-router-extras@0.1.3',
  'jquery@3.1.1',
  'moment@2.17.0',
  'lodash@4.17.2'];

bower.commands.install(bowerDependencies, {save: true})
.on('end', function (installed) {
                    console.log(installed);
                });

我想在 bower api (bower.commands.install) 中配置分辨率和覆盖,还可以配置通过bower.commands.install 执行完整的bower.json 文件。

【问题讨论】:

    标签: node.js bower


    【解决方案1】:

    在配置部分提供分辨率数组和覆盖

    bower.commands.install(bowerDependencies, {save: true}, {/*config resolution and overrides*/})
    .on('end', function (installed) {
                        console.log(installed);
                    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-20
      • 2014-12-15
      • 2011-02-17
      • 2012-10-09
      • 2014-12-27
      • 1970-01-01
      • 1970-01-01
      • 2019-11-16
      相关资源
      最近更新 更多