Webpack 我收到一个错误,配置对象无效。已使用与API架构不匹配的配置对象初始化Web包

Webpack 我收到一个错误,配置对象无效。已使用与API架构不匹配的配置对象初始化Web包,webpack,Webpack,我正在尝试使用WebRTC和React js制作视频通话网站,但每次我做webpack--progress-p时,我都不明白其中的问题是什么 Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.module has an unknown property 'loader

我正在尝试使用WebRTC和React js制作视频通话网站,但每次我做
webpack--progress-p
时,我都不明白其中的问题是什么

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'loaders'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
   -> Options affecting the normal modules (`NormalModuleFactory`).
 - configuration.output.path: The provided value "./public" is not an absolute path!
   -> The output directory as **absolute path** (required).
 - configuration.resolve.extensions[0] should not be empty.
   -> A non-empty string
它显示了上述错误

    import express from 'express';
    import path from 'path';
    import fs from 'fs';
    import http from 'http';
    import https from 'https';
    import sio from 'socket.io';
    import favicon from 'serve-favicon';
    import compression from 'compression';

    const app = express(),
      options = { 
        key: fs.readFileSync(__dirname + '/rtc-video-room-key.pem'),
        cert: fs.readFileSync(__dirname + '/rtc-video-room-cert.pem')
      },
      port = process.env.PORT || 3000,
      server = process.env.NODE_ENV === 'production' ?
        http.createServer(app).listen(port) :
        https.createServer(options, app).listen(port),
      io = sio(server);
    // compress all requests
    app.use(compression());
    app.use(express.static(path.join(__dirname, 'public')));
    app.use((req, res) => res.sendFile(__dirname + '/public/index.html'));
    app.use(favicon('./public/favicon.ico'));
    // Switch off the default 'X-Powered-By: Express' header
    app.disable('x-powered-by');
    io.sockets.on('connection', socket => {
      let room = '';
      const create = err => {
        if (err) {
          return console.log(err);
        }
        socket.join(room);
        socket.emit('create');
      };
      // sending to all clients in the room (channel) except sender
      socket.on('message', message => socket.broadcast.to(room).emit('message', message));
      socket.on('find', () => {
        const url = socket.request.headers.referer.split('/');
        room = url[url.length - 1];
        const sr = io.sockets.adapter.rooms[room];
        if (sr === undefined) {
          // no room with such name is found so create it
          socket.join(room);
          socket.emit('create');
        } else if (sr.length === 1) {
          socket.emit('join');
        } else { // max two clients
          socket.emit('full', room);
        }
      });
      socket.on('auth', data => {
        data.sid = socket.id;
        // sending to all clients in the room (channel) except sender
        socket.broadcast.to(room).emit('approve', data);
      });
      socket.on('accept', id => {
        io.sockets.connected[id].join(room);
        // sending to all clients in 'game' room(channel), include sender
        io.in(room).emit('bridge');
      });
      socket.on('reject', () => socket.emit('full'));
      socket.on('leave', () => {
        // sending to all clients in the room (channel) except sender
        socket.broadcast.to(room).emit('hangup');
        socket.leave(room);});
    });
这段代码有点过时,它是在2018年1月创建的,当时还可以使用,但现在不行了。
另外,当我执行console.log(app.address().port)时,它不会显示端口

将选项加载器更改为规则。这为我解决了问题。希望这对其他人有所帮助。

您的网页包配置是什么?错误会自行说明,但会显示您的配置