Azure Pipeline执行npx cypress run报错:找不到调试日志且NPM返回码1
Azure Pipeline执行
npx cypress run返回码1的排查与解决 报错信息
2022-08-12T07:37:38.5420694Z ##[warning]Couldn't find a debug log in the cache or working directory
2022-08-12T07:37:38.5433010Z ##[error]Error: Npm failed with return code: 1
解决步骤
强制重装依赖
在执行Cypress命令前,先执行依赖安装命令,确保Cypress二进制文件完整无损坏:- script: | npm ci npx cypress run displayName: 'Run Cypress tests'输出Cypress调试日志
添加环境变量打印详细日志,定位具体失败原因:
Windows环境:- script: | set CYPRESS_DEBUG=* npx cypress run displayName: 'Run Cypress with debug logs'Linux/macOS环境:
- script: | CYPRESS_DEBUG=* npx cypress run displayName: 'Run Cypress with debug logs'匹配兼容的Node.js版本
通过setup-node任务指定与当前Cypress版本兼容的Node.js版本:- task: NodeTool@0 inputs: versionSpec: '18.x' # 替换为项目兼容的版本 displayName: 'Install Node.js'验证Cypress安装完整性
先执行验证命令确认Cypress二进制文件正常:- script: npx cypress verify displayName: 'Verify Cypress installation'指定正确工作目录
确保任务工作目录指向包含package.json的项目根目录:- script: npx cypress run workingDirectory: '$(System.DefaultWorkingDirectory)/your-project-path' displayName: 'Run Cypress tests'
内容的提问来源于stack exchange,提问作者ksk
相关产品推荐
相关产品推荐

