使用'npx microbundle'命令gettig错误在jenkins中构建nodejs应用程序
Posted
技术标签:
【中文标题】使用\'npx microbundle\'命令gettig错误在jenkins中构建nodejs应用程序【英文标题】:Building nodejs app in jenkins using 'npx microbundle' command gettig error使用'npx microbundle'命令gettig错误在jenkins中构建nodejs应用程序 【发布时间】:2021-10-04 19:13:09 【问题描述】:[管道] sh
npx microbundle-crl build --target web --external none --format umd --name ReferralSdk --css inline npx:在 29.549 秒内安装了 513 [31m[1mError: 'createLogger' 不是由 node_modules/redux-logger/dist/redux-logger.js 导出,由 src/store/ConfigStore.js 导入[39m[22m在 /var/lib/jenkins/workspace/referral-sdk-js_jenkins-deploy/src/store/ConfigStore.js:2:9
[2m1: import applyMiddleware, compose, createStore from "redux"; 2:从“redux-logger”导入 createLogger ^ 3:从“../redux”导入reducer; 4:从“redux-thunk”导入thunk;[22m
这里是 configStore.js 文件
import applyMiddleware, compose, createStore from "redux";
import createLogger from 'redux-logger'
import reducers from "../redux";
import thunk from "redux-thunk";
const middleware = [createLogger(),thunk]
const ConfigStore = () =>
let store = null;
store = createStore(reducers,,compose(applyMiddleware(...middleware)))
return store
export default ConfigStore()
package.json
"name": "my-project",
"version": "0.1.0",
"private": true,
"dependencies":
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"infinite-react-carousel": "^1.2.11",
"nuka-carousel": "^4.6.6",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-items-carousel": "^2.8.0",
"react-meta-tags": "^0.7.4",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0"
,
"scripts":
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
,
"eslintConfig":
"extends": "react-app"
,
"browserslist":
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
【问题讨论】:
能否把src/store/ConfigStore.js
的源代码贴出来
【参考方案1】:
您好,欢迎,
所以错误来自src/store/ConfigStore.js
ReactJs 源代码的第 2 行
错误来自您尝试从 redux-logger
包中导入 createLogger
的导入语句,但找不到该函数。
这是这里的行:
import createLogger from 'redux-logger';
找不到createLogger或者没有导出。
这似乎是包的错误,您将在其中找到一些解决方案:https://github.com/LogRocket/redux-logger/issues/233
一些可能的解决方案是:
升级或降级软件包,方法是转到package.json
并找到依赖项 react-logger
并找到正确导出此函数的适当版本
根据您使用的捆绑程序(例如 webpack 或 rollup),也许可以尝试问题中的一些解决方案,例如
import * as logger from 'redux-logger';
logger.__moduleExports.createLogger;
如果您使用的是 typescript(它看起来不像),请记住包含 @types,例如npm i @types/redux-logger
【讨论】:
【参考方案2】:但我的代码中已经有这个,我仍然在导出时遇到错误
import applyMiddleware, compose, createStore from "redux";
import createLogger from 'redux-logger'
import reducers from "../redux";
import thunk from "redux-thunk";
const middleware = [createLogger(),thunk]
const ConfigStore = () =>
let store = null;
store = createStore(reducers,,compose(applyMiddleware(...middleware)))
return store
export default ConfigStore()
这是我的 package.json
"dependencies":
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"infinite-react-carousel": "^1.2.11",
"nuka-carousel": "^4.6.6",
"react": "^16.13.0 ",
"react-dom": "^16.13.0",
"react-items-carousel": "^2.8.0",
"react-meta-tags": "^0.7.4",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"rollup-plugin-commonjs": "^10.1.0"
【讨论】:
以上是关于使用'npx microbundle'命令gettig错误在jenkins中构建nodejs应用程序的主要内容,如果未能解决你的问题,请参考以下文章