gpt4 book ai didi

javascript - Webpack.config.js : Configuration has an unknown property 'default'

转载 作者:行者123 更新时间:2023-12-05 05:11:31 28 4
gpt4 key购买 nike

我已将工作项目(最终热重载示例)中的所有内容移至我现有的使用 keystone cms 的项目。我卸载了项目中的所有开发依赖项,并将工作项目中的所有确切依赖项安装到我的项目中(webpack、babel 等...)。

由于某些原因,web.config.js 文件不会解析 es6 语法

export default 

这给出了这个错误:

- configuration has an unknown property 'default'.

如果我切换到以下内容,它会起作用:

const config = ...
module.exports = config;

在我项目的其他地方,我使用了其他 es6 语法并且它有效...

这是 package.json 中的依赖项,它与使用“export default”语法的示例项目完美配合。

"dependencies": {
"babel-cli": "^6.10.1",
"babel-core": "^6.10.4",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.1",
"babel-plugin-react-transform": "^3.0.0",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.11.1",
"babel-register": "^6.9.0",
"babel-runtime": "^6.9.2",
"chokidar": "^2.0.3",
"css-loader": "^0.28.11",
"css-modules-require-hook": "^4.0.1",
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.8.1",
"express": "^4.14.0",
"prop-types": "^15.6.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-hot-loader": "^4.1.3",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"style-loader": "^0.21.0",
"webpack": "^4.8.3",
"webpack-dev-middleware": "^3.1.3",
"webpack-hot-middleware": "^2.12.1",
"webpack-node-externals": "^1.7.2"

知道为什么会这样吗?

最佳答案

我有一个类似的问题,后来变成了我从 require(...)import(...) 的不正确迁移

我替换了这段代码:

const common = require("./webpack.common");
module.exports = merge(common, {...})

与:

const common = await import("./webpack.common.js");
export default merge(common, .....)

问题是我没有使用 webpack.common.jsdefault 导出。修复是:

const common = await import("./webpack.common.js");
export default merge(common.default, .....)

关于javascript - Webpack.config.js : Configuration has an unknown property 'default' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55362294/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com