Javascript “如何修复”;找不到模块';fs额外';-“错误”;在jenkins中部署cypress文件时?

Javascript “如何修复”;找不到模块';fs额外';-“错误”;在jenkins中部署cypress文件时?,javascript,testing,automated-tests,cypress,end-to-end,Javascript,Testing,Automated Tests,Cypress,End To End,我正在使用cypress中的插件,请参阅。当我们把他们部署到詹金斯的时候,我 `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

我正在使用cypress中的插件,请参阅。当我们把他们部署到詹金斯的时候,我

 `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'
我确实经历了几个线程,手动要求您在node_模块中下载fs extra。我这样做了,依赖项已自动添加到package.json文件中。但是,构建失败了。当您在本地运行并且所有测试都通过时,代码可以完美地运行。然而,当部署到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)

}

该代码应该在Jenkins上成功部署,但是,在node_模块上本地安装它是不起作用的。有人能帮我找出我遗漏了什么吗?

这个问题已经解决了。感谢@J先生。这与fs extra无关。docker文件中的入口点不正确,我必须修改它。修改后,效果良好

如果你有这个问题, 1.尝试在节点_模块内安装fs extra。 2.请检查cypress配置文件中的路径。
3.检查docker文件中的路径。

甚至尝试将fs extra从开发人员依赖项移动到依赖项,但仍然不起作用。fs extra似乎不是您的问题,但这是您的问题:
pluginsFile`设置为`/e2e/cypress/plugins/index.js
是否可以验证
/e2e/cypress/plugins/index.js
是否存在?我猜cypress配置对于pluginsFile是不正确的,并且指向一个不存在的文件。你是对的。这与fs extra无关。但是,我们部署到Jenkins中的文件没有正确的入口点。所以我必须改变这一点。在那之后,它工作得很好:)谢谢a托尼,我有这个问题,想知道它是如何解决的。我对docker的入口点不太确定。在我的yaml文件中,我有如下内容:
image:cypress/included:6.3.0
(虽然我现在使用bitbucket管道,但在我以前的工作中,TeamCity也有同样的问题)。