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

使用Playwright执行测试时遇npm ERR! could not determine executable to run错误求助

问题解决方法
  • 修正命令拼写错误
    你输入的命令存在拼写错误:将playwright误写为playright,这是触发错误的核心原因。正确的执行命令应为:

    npx playwright test
    
  • 确认测试文件结构
    Playwright默认扫描tests目录下的*.spec.ts/*.spec.js测试文件,如果你的项目还没有测试文件,可以执行以下命令生成示例测试结构:

    npx playwright init
    
  • 配置package.json脚本(可选)
    为了更方便地运行测试,可在package.json的scripts字段中添加测试命令:

    {
      "name": "project01",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "playwright test"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "@playwright/test": "^1.25.2"
      }
    }
    

    之后只需执行npm run test即可启动测试。

内容的提问来源于stack exchange,提问作者Huckleberry Carignan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 18:30:58