npmのインストールでError: CERT_UNTRUSTEDの対処方法

スポンサーリンク

npmのインストールをしようとするError: CERT_UNTRUSTEDエラーが発生する

以下のコマンドを実行するとエラーが発生します。

$ npm install ejs

npm ERR! Error: CERT_UNTRUSTED
npm ERR! at SecurePair. (tls.js:1430:32)
npm ERR! at SecurePair.emit (events.js:92:17)
npm ERR! at SecurePair.maybeInitFinished (tls.js:1029:10)
npm ERR! at CleartextStream.read [as _read] (tls.js:521:13)
npm ERR! at CleartextStream.Readable.read (_stream_readable.js:341:10)
npm ERR! at EncryptedStream.write [as _write] (tls.js:418:25)
npm ERR! at doWrite (_stream_writable.js:226:10)
npm ERR! at writeOrBuffer (_stream_writable.js:216:5)
npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:183:11)
npm ERR! at write (_stream_readable.js:602:24)
npm ERR! If you need help, you may report this log at:
npm ERR!
npm ERR! or email it to:
npm ERR!

npm ERR! System Linux 2.6.32-642.el6.x86_64
npm ERR! command “node” “/usr/bin/npm” “install” “-g” “n”
npm ERR! cwd /home/vagrant/nodejs_lessons
npm ERR! node -v v0.10.48
npm ERR! npm -v 1.3.6
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/vagrant/nodejs_lessons/npm-debug.log
npm ERR! not ok code 0

環境

環境は以下のとおりです

$ npm -v
1.3.6
$ node --version
v0.10.48
$ cat /etc/redhat-release
CentOS release 6.10 (Final)

解決方法

https のレジストリに対して、SSL 鍵のバリデーションを行っていることが原因らしいので、一旦この設定を false にすると npm install が成功するようになる。npm install 後には true に戻しておく。

$ npm config set strict-ssl false
$ npm install hoge
$ npm config set strict-ssl true

よくわからないことをやっていて心配な人はちゃんとtrueに戻っているか確認することができます

$ npm config get strict-ssl true
true

コメント

タイトルとURLをコピーしました