【问题标题】:Not able to launch Cypress Runner无法启动 Cypress Runner
【发布时间】:2020-04-16 13:09:34
【问题描述】:

当我输入命令C:\Users\gurpr\Documents\Cypress_demo>node_modules\.bin\cypress open 时,出现错误

    Error: Cannot find module 'C:\Users\gurpr\Documents\Cypress_demo\node_modules\cypress\bin\cypress'
    [90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
     [90m    at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
    [90m    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)[39m
    [90m    at internal/main/run_main_module.js:17:11[39m {
      code: [32m'MODULE_NOT_FOUND'[39m,
      requireStack: []
    }

【问题讨论】:

  • 欢迎来到 Stack Overflow。你做了npm install 吗?

标签: cypress runner


【解决方案1】:

全局安装 Cypress(不推荐)
为了使cypress open 能够按预期工作,您需要全局安装 cypress npm install cypress -g。我不肯定赛普拉斯为什么不鼓励这样做,但它可能与版本控制有关。如果您全局安装和使用cypress open,您可能使用的版本与 package.json 中指定的版本不同。如果您在使用全局安装的 cypress 实例运行测试而他们使用 package.json 版本运行 cypress 时得到不同的结果,您的团队将会感到沮丧。命令行的行为也会有所不同。我不会这样做。

使用npx 打开/运行赛普拉斯
我在 package.json 脚本定义中使用 npx cypress opennpx cypress run

在全球范围内卸载赛普拉斯
你想避免对你的团队说“在我的机器上工作......”。如果你没有,我会在全球范围内卸载 cypress。 npm uninstall cypress -g

【讨论】:

    【解决方案2】:

    您可以使用npm install cypress -g 安装cypress 并使用:cypress open 打开

    如果您安装 cypress 只是为了练习,我建议您使用这种方式。它会解决你的问题。

    【讨论】:

      猜你喜欢
      • 2021-04-22
      • 2014-06-19
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      • 2022-01-01
      • 2012-10-10
      • 2019-02-24
      • 2021-09-17
      相关资源
      最近更新 更多