解决方法“已安装cypress npm软件包,但缺少Cypress二进制文件。”

时间:2020-06-11 07:58:13

标签: docker npm gitlab-ci cypress

我正在尝试在GitLab CI运行程序中下载并安装Cypress,并得到以下错误输出:

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

虽然没有解决办法。

以下是发生错误的相关行:

在Dockerfile内部:

COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
RUN npm ci

在测试跑步者内部:

docker-compose -f docker-compose-prod.yml up -d --build
./node_modules/.bin/cypress run --config baseUrl=http://localhost

在package.json内部:

{
  "name": "flask-on-docker",
  "dependencies": {
    "cypress": "^4.8.0"
  }
}

有人能指出我正确的方向吗?

2 个答案:

答案 0 :(得分:1)

您可能正在两个不同的阶段运行npm installcypress run。在这种情况下,无法保留赛普拉斯缓存,因此建议在运行CYPRESS_CACHE_FOLDERinstall时使用cypress run/open选项。该命令将如下所示,

CYPRESS_CACHE_FOLDER=./tmp/Cypress yarn install

CYPRESS_CACHE_FOLDER=./tmp/Cypress npx cy run [--params]

答案 1 :(得分:0)