如何解决"The cypress npm package is installed, but the Cypress binary is missing."



我正在尝试在 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

在包内.json:

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

谁能指出我正确的方向?

您可能在两个不同的阶段运行npm installcypress run。在这种情况下,赛普拉斯缓存无法持久化,因此建议在运行install以及cypress run/openCYPRESS_CACHE_FOLDER选项。该命令将如下所示,

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

这对我有帮助(Windows(:

.node_modules.bincypress.cmd install --force

或者,如果您使用的是 UNIX 系统:

./node_modules/.bin/cypress install --force

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

在运行测试之前yarn cypress install --force对我有用

我遇到了同样的问题 我运行此代码以授予 jenkins 用户成为我的赛普拉斯项目文件夹的所有者 在那之后一切都很好。

sudo chown -R Jenkins:/Your Cypress Project Path/

相关内容

最新更新