Help us understand the problem. What is going on with this article?

yarnで Error: self signed certificate in certificate chain と認証エラーが発生したら

いつしか yarn global 系のコマンドで以下のエラーが出るようになっていた。

yarn Error: self signed certificate in certificate chain

内容としては、オレオレ証明書を許さないって感じな気がする。

yarn のconfigを確認しよう

yarn config list

で一覧を出しましょう。以下のようなものが出ます。

yarn config v1.15.2
info yarn config
{ 'version-tag-prefix':
   'v',
  'version-git-tag':
   true,
  'version-commit-hooks':
   true,
  'version-git-sign':
   false,
  'version-git-message':
   'v%s',
  'init-version':
   '1.0.0',
  'init-license':
   'MIT',
  'save-prefix':
   '^',
  'bin-links':
   true,
  'ignore-scripts':
   false,
  'ignore-optional':
   false,
  registry:
   'https://registry.yarnpkg.com',
  'strict-ssl':
   true,
  'user-agent':
   'yarn/1.15.2 npm/? node/v10.15.3 darwin x64',
  lastUpdateCheck:
   1570528586389 }

重要なのは 'strict-ssl': true, のところです。
ここが 'strict-ssl': true, だとオレオレ証明書に対して、この記事の取り扱っている対象のエラーが発生します。

証明書に関してのエラーを許可する

ということで、strictにならなくていいからさ、ということでconfigを上書きします。

yarn config set strict-ssl false

これで、 'strict-ssl': false, に変わります。

はい、解決しましたとさ。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away