我已经运行了 webpack --mode production 来构建 dist 文件夹,但是当我运行服务器时它显示此错误,该应用程序正在开发人员模式下运行。我收到这个错误:C:\Users\Bymet\Documents\Gestor de Inventario\frontend-admin\node_modules\webpack\lib\webpack.js:31 抛出新的 WebpackOptionsValidationError(webpackOptionsValidationErrors); ^WebpackOptionsValidationError:配置对象无效。Webpack 已使用与 API 架构不匹配的配置对象进行初始化。配置应该是一个对象。接下来是这样的:validationErrors: [ {keyword: 'type', dataPath: '', schemaPath: '#/type', params: { type: 'object' }, message: '应该是 object', schema: 'object', ParentSchema: {定义: { ArrayOfStringOrStringArrayValues: { type: 'array', items: [Object] }, ArrayOfStringValues: { type: 'array', items: [Object] }, Entry: { anyOf: [Array] }, EntryDynamic: { 描述: '返回条目对象、条目字符串、条目数组或对这些事物的承诺的函数。', instanceof: 'Function', tsType: '(() => EntryStatic | Promise)'我已将 dotenv 更改为要在 heroku 上部署的依赖项,但它“有效”这是我的服务器和 webpack 配置import express from 'express';import webpack from 'webpack';import { env, port } from '../../config';const app = express();if (env === 'development') { // console.log('Development config'); const webpackConfig = require('../../webpack.config'); const webpackDevMiddleware = require('webpack-dev-middleware') const webpackHotMiddleware = require('webpack-hot-middleware'); const compiler = webpack(webpackConfig); const serverConfig = { port: port, hot: true }; app.use(webpackDevMiddleware(compiler, serverConfig)); app.use(webpackHotMiddleware(compiler));}app.get('*', (req, res) => { res.send(` <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="assets/app.css" type="text/css"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Cestina | Administración </title> </head> <style> body{ margin: 0px; }
1 回答
元芳怎么了
TA贡献1798条经验 获得超7个赞
看起来您正在导出一个函数来创建配置对象,这意味着您必须先调用它,然后再传递给webpack
:
const webpackConfig = require('../../webpack.config')(); // call it before passing
添加回答
举报
0/150
提交
取消