创建Electron/React应用时遇npm ERR_SSL_CIPHER_OPERATION_FAILED错误求助
问题及解决思路
问题描述
试过网上各种解决方案,包括重装Node.js、安装新版OpenSSL、重装Git Bash、允许Git Bash和Node.js通过防火墙,甚至格式化了整个电脑,但都无效。
首次运行报错:
npm WARN exec The following package was not found and will be installed: create-electron-app@6.0.5 npm ERR! code ERR_SSL_CIPHER_OPERATION_FAILED npm ERR! 7C020000:error:1C800066:Provider routines:ossl_gcm_stream_update:cipher operation failed:c:\ws\deps\openssl\openssl\providers\implementations\ciphers\ciphercommon_gcm.c:320: npm ERR!
再次运行后报错:
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty); TypeError: bind.call is not a function at Object.<anonymous> (C:\Users\Keba\AppData\Local\npm-cache\_npx\36f5f21e8c68ce75\node_modules\has\src\index.js:5:23) at Module._compile (node:internal/modules/cjs/loader:1275:14) at Module._extensions..js (node:internal/modules/cjs/loader:1329:10) at Module.load (node:internal/modules/cjs/loader:1133:32) at Module._load (node:internal/modules/cjs/loader:972:12) at Module.require (node:internal/modules/cjs/loader:1157:19) at require (node:internal/modules/helpers:119:18) at Object.<anonymous> (C:\Users\Keba\AppData\Local\npm-cache\_npx\36f5f21e8c68ce75\node_modules\@electron-forge\cli\node_modules\is-core-module\index.js:3:11) at Module._compile (node:internal/modules/cjs/loader:1275:14) at Module._extensions..js (node:internal/modules/cjs/loader:1329:10) Node.js v19.6.1
解决步骤
一、处理SSL加密错误(首次运行报错)
- 切换Node.js稳定版本:当前用的v19.6.1是非稳定版,存在OpenSSL兼容性风险,换成LTS版本(比如v18.x或v20.x)试试。
- 调整npm的SSL配置:执行以下命令强制使用兼容的SSL协议:
npm config set ssl-protocol=TLSv1.2 npm config set strict-ssl false - 彻底清理npm缓存:
npm cache clean --force
二、处理bind.call is not a function错误(再次运行报错)
- 删除缓存的npx依赖包:直接删除报错路径里的缓存文件夹:
rm -rf C:\Users\Keba\AppData\Local\npm-cache\_npx\36f5f21e8c68ce75 - 全局安装后再执行:避免npx临时安装的版本冲突,先全局装最新版
create-electron-app:npm install -g create-electron-app@latest create-electron-app your-app-name - 检查环境变量:确保系统
PATH里没有旧版Node.js/npm的残留路径,避免版本冲突。
三、额外排查点
- 关闭杀毒/安全工具:部分安全软件会拦截Node.js的加密操作,导致SSL错误,暂时关闭后重试。
- 用管理员权限运行终端:右键Git Bash或CMD选择「以管理员身份运行」,再执行命令。
内容的提问来源于stack exchange,提问作者Hussain AlAdraj
相关产品推荐
相关产品推荐

