0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ZScaler 配下でnpm install ができなかったときの対応方法

Last updated at Posted at 2025-05-15

はじめに

先日 メイン環境がWindowsに変わったためにやったこと・覚えたこと という記事を書いたのですが、数ヶ月が経過し MacBook Pro 環境が戻ってきました。

これでほぼ前職のNTTコミュニケーションズ時代とおなじになり、かなり各種作業が楽になりました。

一方で、実は前職では業務上の都合で使用していなかった ZScaler の導入を余儀なくされたという差分だけが出てます。
この状況で開発のために npm install したらいきなり以下のエラーとなりまして、それをどうやって回避したか?というのが本記事の内容です。
(pyalwright-mcp を試そうとしたところハマった)

% npm install                                                                           
npm error code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm error errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm error request to https://registry.npmjs.org/playwright-core/-/playwright-core-1.53.0-alpha-1746832516000.tgz failed, reason: unable to get local issuer certificate
npm error A complete log of this run can be found in: /Users/[username]/.npm/_logs/2025-05-15T05_28_23_642Z-debug-0.log

やったこと

こちら に書かれているんですね。
(社内で質問したら、同じく社内の方がすぐに教えてくださったので感謝)

具体的には、証明書を何かしらのパスに保存します。
キーチェーン上の名前は「Zscaler Root CA」らしいので以下を実行します。

保存ファイル名は ca-bundle.pem としていますが、実際には何でも良いです。

cd [保存したい場所]

security find-certificate -p -c "Zscaler Root CA" > ca-bundle.pem

npm config set cafile /path/to/ca-bundle.pem

echo "export NODE_EXTRA_CA_CERTS=/path/to/bundle.pem" >> $HOME/.zshrc

source ~/.zshrc

これで npm install が通るようになりました。

% npm install                                                                         

added 312 packages, and audited 313 packages in 32s

119 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

これで快適な環境が戻ってきました。

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?