在 运行 bower install 命令时无法为 angular 找到合适的版本

Unable to find a suitable version for angular while running bower install command

我在执行 运行 bower install 命令时收到以下消息。

bower.json:

{
  "name": "test-app",
  "version": "1.1.6",
  "dependencies": {
               "jquery": "2.1.0",
               "jquery-bridget": "*",
    "angular": "1.3.15",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "angular-resource": "1.3.15",
    "angular-sanitize": "1.3.15",
    "angular-animate": "1.3.15",
    "angular-cookies": "1.3.15",
    "angular-touch": "1.3.15",
    "angular-moment": "~0.6.2",
    "angular-loading-bar": "0.6.0",
    "angular-masonry": "0.11.0",
    "js-cookie": "2.1.3"
  },
  "devDependencies": {
    "angular-mocks": "1.3.15",
    "angular-scenario": "1.3.15"
  }
}

任何人都可以帮助我如何继续前进。

谢谢, 桑托什

那是因为您要注入的依赖项需要不同版本的 angularJs。要解决它,首先要找到合适的angularJs兼容版本。然后您可以将 resolutions 添加到 bower.json 文件中的对象并指定组件名称和版本以在 运行 bower 命令时自动解决冲突。像这样:

{
 "name": "test-app",
 "version": "1.1.6",
 "dependencies": {
           "jquery": "2.1.0",
           "jquery-bridget": "*",
     "angular": "1.3.15",
     "json3": "~3.2.6",
     "es5-shim": "~2.1.0",
     "angular-resource": "1.3.15",
     "angular-sanitize": "1.3.15",
     "angular-animate": "1.3.15",
     "angular-cookies": "1.3.15",
     "angular-touch": "1.3.15",
     "angular-moment": "~0.6.2",
     "angular-loading-bar": "0.6.0",
     "angular-masonry": "0.11.0",
     "js-cookie": "2.1.3"
  },
  "devDependencies": {
     "angular-mocks": "1.3.15",
     "angular-scenario": "1.3.15"
  },
  "resolutions": {
     "angular": "1.3.15"
  }
}

尝试升级到最近的 angular-moment 版本,例如 ~0.10

您可以使用 resolutions 属性明确告诉 bower 安装依赖项的特定版本。像这样:

"dependencies": {
    "jquery": "2.1.0",
    "jquery-bridget": "*",
    ...
}, 
"resolutions": {
    "angular": "1.4.8",
    ...
}