【发布时间】:2022-06-11 01:08:48
【问题描述】:
在我的项目flux-react-router-example中,我的webpack.config.js文件如下:
var path = require('path'); var webpack = require('webpack'); 模块.exports = { 入口: [ 'webpack-hot-middleware/client', './脚本/索引' ], devtool: 'eval-source-map', 输出: { 路径:__dirname, 文件名:'bundle.js', 公共路径:'/静态/' }, 插件:[ 新的 webpack.HotModuleReplacementPlugin(), ], 优化: [ 新的 webpack.optimization.emitOnErrors() ], 模块: { 装载机:[{ 测试:/\.js$/, 装载机:['babel'], 包括:path.join(__dirname, 'scripts') }] } };我在 Visual Studio 代码中的终端是这样说的:
C:\Users\p-c\Downloads\Github\flux-react-router-example\webpack.config.js:20 新的 webpack.optimization.emitOnErrors() ^ TypeError:无法读取未定义的属性(读取“emitOnErrors”) 在对象。 (C:\Users\p-c\Downloads\Github\flux-react-router-example\webpack.config.js:20:30) 在 Module._compile (node:internal/modules/cjs/loader:1105:14) 在 Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) 在 Module.load (node:internal/modules/cjs/loader:981:32) 在 Function.Module._load (node:internal/modules/cjs/loader:822:12) 在 Module.require (node:internal/modules/cjs/loader:1005:19) 在需要(节点:内部/模块/cjs/helpers:102:18) 在对象。 (C:\Users\p-c\Downloads\Github\flux-react-router-example\server.js:4:14) 在 Module._compile (node:internal/modules/cjs/loader:1105:14) 在 Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)我的 webpack 版本是 webpack@5.73.0
我的节点版本是 v16.15.0
我的 npm 版本是 8.3.1
【问题讨论】: