问题描述
在使用npm install cypress --save-dev
安装Cypress
后,不管是直接运行npx cypress open
还是切到node_modules/.bin
目录下运行cypress open
,都会提示未安装cypress
No version of Cypress is installed in: C:\Users\ChenH\AppData\Local\Cypress\Cache\10.9.0\Cypress
Please reinstall Cypress by running: cypress install
由于网络原因(公司局域网),无法按照提示运行cypress install
原因分析
与npm run
一样,npx cypress open
也会到node_modules/.bin
目录下找可执行文件(.cmd
和.ps1
),去看了下.bin
文件夹下果然没有cypress
的可执行文件
解决方案
既然不能通过命令行下载,那就直接下载到本地
这里提供两种解决方案:
先从先从https://download.cypress.io/desktop.json下载对应版本的安装包,这里是v10.9.0
方法1:自行解压缩后,CV到C:\Users\ChenH\AppData\Local\Cypress\Cache\10.9.0\Cypress
下
方法2:命令行运行set CYPRESS_INSTALL_BINARY=d:\cypress.zip
设置环境变量为该压缩包的路径,然后重新运行npm i cypress -D
然后再运行npx cypress open
就可以打开Cypress
了