You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux系统下无法安装Bower的问题求助

安装Bower时遇到CERT_UNTRUSTED错误的解决方法

问题背景

我在Linux Mint 17.2 Rafaela系统上尝试安装Bower,已经预装了node v0.10.25和npm 1.3.10。执行安装命令:

sudo npm install -g bower

后出现了以下错误信息:

npm http GET https://registry.npmjs.org/bower 
npm http GET https://registry.npmjs.org/bower 
npm http GET https://registry.npmjs.org/bower 
npm ERR! Error: CERT_UNTRUSTED 
npm ERR! at SecurePair.<anonymous> (tls.js:1370:32) 
npm ERR! at SecurePair.EventEmitter.emit (events.js:92:17) 
npm ERR! at SecurePair.maybeInitFinished (tls.js:982:10) 
npm ERR! at CleartextStream.read [as _read] (tls.js:469:13) 
npm ERR! at CleartextStream.Readable.read (_stream_readable.js:320:10) 
npm ERR! at EncryptedStream.write [as _write] (tls.js:366:25) 
npm ERR! at doWrite (_stream_writable.js:223:10) 
npm ERR! at writeOrBuffer (_stream_writable.js:213:5) 
npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:180:11) 
npm ERR! at write (_stream_readable.js:583:24) 
npm ERR! If you need help, you may report this log at: 
npm ERR! <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR! <npm-@googlegroups.com> 
npm ERR! System Linux 4.4.0-109-generic 
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "bower" 
npm ERR! cwd / 
npm ERR! node -v v0.10.25 
npm ERR! npm -v 1.3.10 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR! /npm-debug.log 
npm ERR! not ok code 0

解决办法

别着急,这个CERT_UNTRUSTED错误本质是你的npm版本过于陈旧,无法适配npm官方仓库当前的SSL证书验证规则。下面几个方法都能解决问题,你可以根据情况选择:

  • 临时跳过SSL验证快速安装
    这是最直接的临时方案,执行命令时添加跳过SSL检查的参数:

    sudo npm install -g bower --strict-ssl false
    

    注意:这个方法只是临时绕过验证,不建议长期使用,后续最好还是更新依赖版本。

  • 更新npm到兼容版本
    先把npm升级到和你的node v0.10.25兼容的较新版本(比如npm 2.x系列),同样需要先跳过SSL验证来完成升级:

    sudo npm install -g npm@2.x --strict-ssl false
    

    升级完成后,再正常执行Bower的安装命令即可:

    sudo npm install -g bower
    
  • 切换到国内npm镜像源
    国内的镜像源(比如淘宝npm镜像)通常不需要严格的SSL验证,而且访问速度更快。先设置镜像源:

    sudo npm config set registry http://registry.npm.taobao.org/
    

    之后直接安装Bower就不会有证书问题了:

    sudo npm install -g bower
    

内容的提问来源于stack exchange,提问作者MariaMaria1

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:43:39