gyp ERR,Npm 无法获取本地颁发者证书
gyp ERR, Npm is unable to get local issuer certificate
我正在清理 Windows 10 安装。只有我安装的 cygwin 可以在 cmd 中获取 unix 命令。
当我键入 npm install -g @angular/cli
时,它会下载必要的文件,但我收到错误消息:
gyp ERR! configure error
gyp ERR! stack Error: unable to get local issuer certificate
gyp ERR! stack at Error (native)
gyp ERR! stack at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
gyp ERR! stack at emitNone (events.js:86:13)
gyp ERR! stack at TLSSocket.emit (events.js:185:7)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:610:8)
gyp ERR! stack at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\node-sass
gyp ERR! node -v v6.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
我像 'npm config edit' 一样编辑了 npm 配置文件。在打开的文件中,我添加了以下设置:
strict-ssl=false
http_proxy=null
proxy=null
但这不起作用,我仍然收到同样的错误。更重要的是,npm install
也以相同的结果中断。
我遇到了同样的问题。
下面解决了我的问题
set NODE_TLS_REJECT_UNAUTHORIZED=0
然后npm install
又
@Emon 的回答是正确的,但是对于 Linux 用户来说,命令显然是:
export NODE_TLS_REJECT_UNAUTHORIZED=0
在您的系统上找到证书包,然后将环境变量 NODE_EXTRA_CA_CERTS 设置为该路径。
find / -name *.crt
/etc/ssl/certs/ca-certificates.crt
/usr/share/ca-certificates/full_bundle.crt
/usr/share/ca-certificates/mozilla/DigiCert_Assured_ID_Root_CA.crt
/usr/share/ca-certificates/mozilla/E-Tugra_Certification_Authority.crt
...
您应该会得到很多结果,因此您必须通读它们才能确定正确的 crt 文件。然后:
export NODE_EXTRA_CA_CERTS=/usr/share/ca-certificates/full_bundle.crt
我正在清理 Windows 10 安装。只有我安装的 cygwin 可以在 cmd 中获取 unix 命令。
当我键入 npm install -g @angular/cli
时,它会下载必要的文件,但我收到错误消息:
gyp ERR! configure error
gyp ERR! stack Error: unable to get local issuer certificate
gyp ERR! stack at Error (native)
gyp ERR! stack at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
gyp ERR! stack at emitNone (events.js:86:13)
gyp ERR! stack at TLSSocket.emit (events.js:185:7)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:610:8)
gyp ERR! stack at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\node-sass
gyp ERR! node -v v6.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
我像 'npm config edit' 一样编辑了 npm 配置文件。在打开的文件中,我添加了以下设置:
strict-ssl=false
http_proxy=null
proxy=null
但这不起作用,我仍然收到同样的错误。更重要的是,npm install
也以相同的结果中断。
我遇到了同样的问题。 下面解决了我的问题
set NODE_TLS_REJECT_UNAUTHORIZED=0
然后npm install
又
@Emon 的回答是正确的,但是对于 Linux 用户来说,命令显然是:
export NODE_TLS_REJECT_UNAUTHORIZED=0
在您的系统上找到证书包,然后将环境变量 NODE_EXTRA_CA_CERTS 设置为该路径。
find / -name *.crt
/etc/ssl/certs/ca-certificates.crt
/usr/share/ca-certificates/full_bundle.crt
/usr/share/ca-certificates/mozilla/DigiCert_Assured_ID_Root_CA.crt
/usr/share/ca-certificates/mozilla/E-Tugra_Certification_Authority.crt
...
您应该会得到很多结果,因此您必须通读它们才能确定正确的 crt 文件。然后:
export NODE_EXTRA_CA_CERTS=/usr/share/ca-certificates/full_bundle.crt