cypress 无法启动No version of Cypress is installed in: /Users/xxx/Library/Caches/Cypress/13.3.3/Cypress.app

发布时间 2023-10-26 11:08:56作者: 蓝色的天_90

使用npx cypress open

启动cypress 提示 

No version of Cypress is installed in: /Users/xxx/Library/Caches/Cypress/13.3.3/Cypress.app

 npx cypress open
No version of Cypress is installed in: /Users/xxx/Library/Caches/Cypress/13.3.3/Cypress.app

Please reinstall Cypress by running: cypress install

----------

Cypress executable not found at: /Users/xxx/Library/Caches/Cypress/13.3.3/Cypress.app/Contents/MacOS/Cypress

----------

Platform: darwin-x64 (19.6.0)
Cypress Version: 13.3.3

 

如何解决呢:

这是因为安装的cypress包只是跑测试用例的代码, 而控制浏览器完成自动化测试的是通过Cypress应用程序进行的。
  既然如此,我们就按照提示安装Cypress应用程序:
npx cypress install
结果发现根本装不下来,每次都是到1%的进度就断掉或者没有进展(
  百度谷歌、stackoverflow、github 上查了半天,最终是无意之间在 Github 上的 issue 上找到了解决办法。需要在安装命令后面加上--force:
npx cypress install --force

本以为这样就ok 了但是又报错了 

Error: EACCES: permission denied, mkdir '/Users/xxx/Library/Caches/Cypress/13.3.3'
 npx cypress install --force
Installing Cypress (version: 13.3.3)

✔  Downloaded Cypress
The Cypress App could not be unzipped.

Search for an existing issue or open a GitHub issue at

https://github.com/cypress-io/cypress/issues

----------

Error: EACCES: permission denied, mkdir '/Users/xxx/Library/Caches/Cypress/13.3.3'

----------

Platform: darwin-x64 (19.6.0)
Cypress Version: 13.3.3

于是使用超级管理员模式

sudo su
Password:
sh-3.2# npx cypress install --force

Cypress 13.3.3 is installed in /var/root/Library/Caches/Cypress/13.3.3

Installing Cypress (version: 13.3.3)

✔  Downloaded Cypress
✔  Unzipped Cypress
✔  Finished Installation /var/root/Library/Caches/Cypress/13.3.3

You can now open Cypress by running: node_modules/.bin/cypress open

https://on.cypress.io/installing-cypress

这下终于好了,看到了希望

使用命令

node_modules/.bin/cypress open 
打开看到了久违的界面