簡體   English   中英

將賽普拉斯文件部署到jenkins中時,如何解決“找不到模塊'fs-extra'-錯誤”的問題?

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

我在cypress中使用插件,並引用了https://docs.cypress.io/api/plugins/configuration-api.html#Usage 當我們將它們部署到詹金斯時,

 `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_module中下載fs-extra。 我做到了,並且依賴項已自動添加到package.json文件中。 但是,構建失敗。 當您在本地運行並通過所有測試時,代碼可以完美運行。 但是,當部署到詹金斯時,此操作將失敗。


// 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_module上本地安裝它。 有人可以幫我弄清楚我所缺少的嗎?

此問題已得到解決。 感謝@ Mr.J。 這與fs-extra無關。 泊塢窗文件中的入口點不正確,我必須對其進行修改。 修改后,它工作正常。

如果完全有此問題,請執行以下操作:1.嘗試在node_module內安裝fs-extra。 2.請檢查cypress配置文件中的路徑。 3.檢查泊塢窗文件中的路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM