You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Angular后创建新项目遇npm SSL加密操作失败错误求助

问题描述

从Angular 12升级后,执行以下命令全局重装Angular CLI:

ng version
npm uninstall -g @angular/cli 
npm cache clean
npm cache clean --force
npm cache verify
npm install -g @angular/cli
ng version

创建新项目时(选择不启用Angular路由、使用SCSS样式),出现SSL加密相关错误,错误信息如下:

- Installing packages (npm)...npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm ERR! code ERR_SSL_CIPHER_OPERATION_FAILED
npm ERR! AC0A0000: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!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\PC-Bengkel\AppData\Local\npm-cache\_logs\2023-04-12T04_09_27_982Z-debug-0.log
× Package install failed, see above.
The Schematic workflow failed. See above.

当前环境版本信息:

Angular CLI: 15.2.5
Node: 18.15.0
Package Manager: npm 9.5.0
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1502.5 (cli-only)
@angular-devkit/core         15.2.5 (cli-only)
@angular-devkit/schematics   15.2.5 (cli-only)
@schematics/angular          15.2.5 (cli-only)

已尝试删除项目文件夹后重试,问题依旧。

解决方案

针对ERR_SSL_CIPHER_OPERATION_FAILED错误,可按以下步骤排查修复:

  • 禁用npm的SSL严格模式
    执行命令临时跳过SSL证书校验:

    npm config set strict-ssl false
    

    完成项目创建后,可根据需求恢复SSL严格模式:

    npm config set strict-ssl true
    
  • 切换npm镜像源
    国内环境建议切换到国内镜像,避免SSL连接问题:

    npm config set registry https://registry.npmmirror.com/
    
  • 调整Node.js版本
    Node.js 18.x部分版本与OpenSSL的GCM加密存在兼容性问题,可尝试:

    • 升级到Node.js 18.x最新稳定版
    • 或降级到Node.js 16.x LTS版本
  • 彻底清理缓存并重装
    执行以下命令清理缓存后,重新创建项目:

    npm cache clean --force
    # 若已有项目文件夹,先删除依赖文件
    rm -rf node_modules package-lock.json
    npm install
    
  • 检查系统SSL证书

    • 确认Windows系统根证书是否完整,尝试更新系统证书
    • 若使用代理,检查代理设置是否干扰SSL连接

内容的提问来源于stack exchange,提问作者rheza 555

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 06:29:54