34

我正在使用 git bash 在 Windows 中构建一个角度应用程序,到目前为止,我已经能够使用 yo 搭建脚手架,没有问题,但是当我尝试发出以下命令时。有人可以指点我解决这个问题。

凉亭安装角度引导

我收到以下错误:

bower error         Request to https://bower.herokuapp.com/packages/angular-reso
urce failed: SELF_SIGNED_CERT_IN_CHAIN

Stack trace:
Error: Request to https://bower.herokuapp.com/packages/angular-resource failed:
SELF_SIGNED_CERT_IN_CHAIN
    at createError (c:\Users\arusarka\AppData\Roaming\npm\node_modules\bower\nod
e_modules\bower-registry-client\lib\util\createError.js:2:15)
    at Request._callback (c:\Users\arusarka\AppData\Roaming\npm\node_modules\bow
er\node_modules\bower-registry-client\lib\lookup.js:97:29)
    at self.callback (c:\Users\arusarka\AppData\Roaming\npm\node_modules\bower\n
ode_modules\request\request.js:129:22)
    at Request.EventEmitter.emit (events.js:95:17)
    at Request.request.emit (c:\Users\arusarka\AppData\Roaming\npm\node_modules\
bower\node_modules\bower-registry-client\node_modules\request-replay\index.js:69
:33)
    at ClientRequest.self.clientErrorHandler (c:\Users\arusarka\AppData\Roaming\
npm\node_modules\bower\node_modules\request\request.js:239:10)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1528:9)
    at CleartextStream.EventEmitter.emit (events.js:95:17)
    at SecurePair.<anonymous> (tls.js:1368:19)
4

5 回答 5

70

它终于对我有用。这些是我采取的步骤:

  1. 从 npm 卸载 bowernpm uninstall bowernpm uninstall -g bower
  2. 从 npm 安装 bower-canarynpm install bower-canarynpm install -g bower-canary
  3. 在您的项目目录中创建.bowerrc以下内容以关闭 SSL:
{ "strict-ssl": false,  "https-proxy": "" }
  1. 然后再试一次bower install angular-bootstrap
于 2013-12-13T21:17:45.550 回答
25

Search for .bowerrc in your npm folder of Appdata, open the file and include the properties mentioned by natdico as follows:

{
    "directory": "bower_components",
    "strict-ssl": false, 
    "https-proxy": ""
}
于 2015-04-13T10:36:31.747 回答
15

如果您有权访问属于您的链的自签名 CA 证书,则可以将其添加到您的.bowerrc文件中,如下所示:

{
  ...
  "ca": "/path/to/cacert.pem",
  ...
}

而不是像其他答案所建议的那样禁用 SSL。

禁用 SSL 将使您解决此问题。但是,这样做会带来在未来为自己制造一些更大问题的风险。

Bower 的文档

于 2017-01-19T08:43:27.190 回答
1

将以下行添加到.bowerrc项目中的文件中directory

"strict-ssl": false,
 "https-proxy": "" .

.bowerrc应该是这样的:

{
 "directory": "app/bower_components",
 "strict-ssl": false,
 "https-proxy": "" 
 }
于 2016-07-27T11:54:40.927 回答
0

尝试通过运行以下命令为 npm 设置注册表配置:

npm config set registry http://registry.npmjs.org/

我试过了,它对我有用。

于 2016-01-25T10:58:25.237 回答