简体   繁体   English

将赛普拉斯文件部署到jenkins中时,如何解决“找不到模块'fs-extra'-错误”的问题?

[英]How to fix “Cannot find module 'fs-extra' - error” When deploying cypress files into jenkins?

I am using plugins in cypress and referred to https://docs.cypress.io/api/plugins/configuration-api.html#Usage . 我在cypress中使用插件,并引用了https://docs.cypress.io/api/plugins/configuration-api.html#Usage When we deploy them into jenkins, I am getting 当我们将它们部署到詹金斯时,

 `pluginsFile` is set to `/e2e/cypress/plugins/index.js`, but either the file is missing, it contains a syntax error, or threw an error when required. The `pluginsFile` must be a `.js` or `.coffee` file.

Please fix this, or set `pluginsFile` to `false` if a plugins file is not necessary for your project.[39m

Error: Cannot find module 'fs-extra'

I did go through a few threads which manually asks you to download the fs-extra in node_module. 我确实经历了一些线程,这些线程手动要求您在node_module中下载fs-extra。 I did that and the dependency has been automatically added into the package.json file. 我做到了,并且依赖项已自动添加到package.json文件中。 However, the build fails. 但是,构建失败。 The code runs perfectly when you run locally and all the test passes. 当您在本地运行并通过所有测试时,代码可以完美运行。 However, this fails when the deployed into jenkins. 但是,当部署到詹金斯时,此操作将失败。


// promisified fs module
const fs = require('fs-extra')
const path = require('path')

function getConfigurationByFile (file) {
  const pathToConfigFile = path.resolve('cypress', 'config', `${file}.json`)

  return fs.readJson(pathToConfigFile)
}

module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
  // accept a configFile value or use development by default
 const file = config.env.configFile || 'environment-2'

 return getConfigurationByFile(file)

}

The code should deploy successfully on Jenkins, however, evening installing it locally on node_module doesn't work. 该代码应该可以在Jenkins上成功部署,但是,晚上不能在node_module上本地安装它。 Can somebody help in figuring out what I am missing, please? 有人可以帮我弄清楚我所缺少的吗?

This issue has been resolved. 此问题已得到解决。 Thanks to @Mr.J. 感谢@ Mr.J。 This had nothing to do with fs-extra. 这与fs-extra无关。 The entry point in docker file was not correct and I had to modify that. 泊坞窗文件中的入口点不正确,我必须对其进行修改。 After modifying that, it worked fine. 修改后,它工作正常。

If at all you have this issue, 1. Try installing fs-extra inside node_module. 如果完全有此问题,请执行以下操作:1.尝试在node_module内安装fs-extra。 2. please check the path in the cypress config file. 2.请检查cypress配置文件中的路径。 3. Check the path in docker file. 3.检查泊坞窗文件中的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM