背景
想参考 codesbiome/electron-react-webpack-typescript-2024: Electron React Webpack Typescript Boilerplate with Custom Window and Titlebar Menus. (github.com) 内容进行学习,发现 yarn install 总失败,并且报 # Hostname/IP does not match certificate‘s altnames: Host: npm.taobao.org 的错误,后续希望将其他 npm 包的安装问题也记录在此。
Hostname/IP does not match certificate‘s altnames
1 设置 npm yarn registry 镜像
npm config set registry https://registry.npmmirror.com
yarn config set registry https://registry.npmmirror.com
2 删除 ELECTRON_MIRROR
npm config delete ELECTRON_MIRROR
yarn config delete ELECTRON_MIRROR
3 设置 strict-ssl
npm config set strict-ssl false
yarn config set strict-ssl false
参考:im_electron_sdk升级: Hostname/IP does not match certificate‘s altnames: Host: npm.taobao.org.-CSDN博客
4 禁用代理加速,笔者本地使用了 瓦特工具箱(Steam++官网) - Watt Toolkit (steampp.net) 代理访问 github 加速,导致后续又出现:
Output:
RequestError: unable to verify the first certificate
然后禁用加速,重试即可安装成功
总结
网络不通真伤呀,一方面 github 访问失败要使用加速代理,一方面 electron 又校验了 certificate 不让代理,很容易导致一些包的 download 失败,真多坑。