vue-cli版本升级4.X到5.X问题

2022-07-18  本文已影响0人  陌小亓

1. options has an unknown property 'overlay'

client: {
    overlay: {
      
    }
}

2. webpack < 5 used to include polyfills for node.js core modules by default.

This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:

configuareWebpack: {
    resolve: {
        alias: {
        },
        fallback:{
            path: require.resolve("path-browserify")
        }
    }
}

3.ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.

经查阅官方文档webpack5-devServer,after和before已弃用,分别用middlewares.pushmiddlewares.unshift替代

devServer: {
    setupMiddlewares: (middlewares, devServer) => {
      if (!devServer) {
        throw new Error('webpack-dev-server is not defined');
      }

      devServer.app.get('/setup-middleware/some/path', (_, response) => {
        response.send('setup-middlewares option GET');
      });
    }
}

4. devServer获取post传递参数undefined

以前的写法

// 安装 body-parser
npm install body-parser
const bodyParser = require(‘body-parser’);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
    extended: true
}));

express 4.X版本不需要额外加载body-parser

const express = require(‘express’);
devServer.app.use(express.json());
devServer.app.use(express.urlencoded({
    extended: true
}));
上一篇下一篇

猜你喜欢

热点阅读