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

运行npx cypress open时出现ERR_FAILED (-2)错误求助

Cypress启动报错ERR_FAILED (-2)的排查方案

问题描述

我基于create-react-app创建了基础项目,仅通过npm i cypress安装Cypress,运行npx cypress open时出现以下错误:

ERR_FAILED (-2) loading 'http://localhost:49770/__launchpad/index.html'
Error: ERR_FAILED (-2) loading 'http://localhost:49770/__launchpad/index.html'
at rejectAndCleanup (node:electron/js2c/browser_init:165:7500)
at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:165:7875)
at EventEmitter.emit (node:events:527:28)
at EventEmitter.emit (node:domain:475:12)

已尝试关闭防火墙、重启电脑,问题仍未解决。

可能的原因及解决方法

  • Cypress安装不完整或损坏
    删除node_modules文件夹、package-lock.json或yarn.lock文件,重新执行npm install,再重新安装Cypress:npm i cypress --save-dev。也可直接清理Cypress缓存:npx cypress cache clear后再启动。

  • Electron网络配置冲突
    Cypress基于Electron运行,可能受系统代理影响。关闭系统代理后重试,或启动时指定无代理模式:npx cypress open --proxy-server=""。

  • 端口被占用
    错误中的49770端口是Cypress启动的launchpad端口,可能被其他进程占用。可指定新端口启动:npx cypress open --port 50000(替换为未被占用的端口);或用netstat/lsof命令排查端口占用进程,杀掉后重试。

  • Node.js版本不兼容
    Cypress对Node.js版本有要求,检查当前版本是否在支持范围内(推荐16.x-20.x)。用nvm切换到兼容版本后重新尝试。

  • 系统权限不足
    以管理员/超级用户权限运行终端,再执行npx cypress open,避免因权限问题导致资源加载失败。

  • Cypress版本存在bug
    尝试降级或升级到稳定版本,比如:npm i cypress@13.6.0 --save-dev(替换为已知稳定的版本号)。

内容的提问来源于stack exchange,提问作者Emre Apaydın

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 17:15:43