首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何解决“安装了cypress npm包,但缺少Cypress二进制文件”。

如何解决“安装了cypress npm包,但缺少Cypress二进制文件”。
EN

Stack Overflow用户
提问于 2020-06-11 15:58:13
回答 2查看 9.1K关注 0票数 13

我尝试在GitLab CI runner中下载并安装Cypress,并得到以下错误输出:

代码语言:javascript
运行
复制
The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: /root/.cache/Cypress/4.8.0/Cypress/Cypress
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.

我运行了建议的命令cypress install,但它没有帮助。接下来,它显示You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress,我不明白如何缓存模块并省略它的路径。接下来是You ran 'npm install' at an earlier build step but did not persist,我在早期的版本中确实有npm install,所以我用npm ci替换了它,在这种情况下,Cypress官方文档中推荐使用它。

但是没有解决方案。

以下是出现错误的相关行:

Dockerfile内部:

代码语言:javascript
运行
复制
COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
RUN npm ci

在测试运行器内部:

代码语言:javascript
运行
复制
docker-compose -f docker-compose-prod.yml up -d --build
./node_modules/.bin/cypress run --config baseUrl=http://localhost

在package.json内部:

代码语言:javascript
运行
复制
{
  "name": "flask-on-docker",
  "dependencies": {
    "cypress": "^4.8.0"
  }
}

谁能给我指个正确的方向?

EN

回答 2

Stack Overflow用户

发布于 2020-07-03 02:47:24

您可能在两个不同的阶段运行npm installcypress run。在这种情况下,cypress缓存无法持久化,因此建议在运行installcypress run/open时使用CYPRESS_CACHE_FOLDER选项。该命令将如下所示,

代码语言:javascript
运行
复制
CYPRESS_CACHE_FOLDER=./tmp/Cypress yarn install

CYPRESS_CACHE_FOLDER=./tmp/Cypress npx cy run [--params]
票数 5
EN

Stack Overflow用户

发布于 2021-07-21 22:08:31

它帮助了我

代码语言:javascript
运行
复制
.\node_modules\.bin\cypress.cmd install --force

https://newbedev.com/the-cypress-npm-package-is-installed-but-the-cypress-binary-is-missing-591-code-example

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62319657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档