《前端》webpack报错:npm ERR! vue-admin-template@4.4.0 dev: `vue-cli-service serve`

曹伟泽
2023-12-01

然后在终端输入npm run dev的时候,提示错误信息:

$ npm run dev

> vue-admin-template@4.4.0 dev
> vue-cli-service serve

 INFO  Starting development server...
 ERROR  ValidationError: webpack Dev Server Invalid Options

options should NOT have additional properties

ValidationError: webpack Dev Server Invalid Options

options should NOT have additional properties

    at validateOptions (F:\2020\练习\Vue\hrsaas\node_modules\_schema-utils@1.0.0@schema-utils\src\validateOptions.js:32:11)
    at new Server (F:\2020\练习\Vue\hrsaas\node_modules\_webpack-dev-server@3.11.2@webpack-dev-server\lib\Server.js:57:5)
    at serve (F:\2020\练习\Vue\hrsaas\node_modules\_@vue_cli-service@4.4.4@@vue\cli-service\lib\commands\serve.js:172:20)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

一般这种错误发生在vue.config.js中

从上往下查找,发现Proxy大写了也会出错!

devServer: {
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    Proxy: {
      '/api': {
        target: 'http://ihrm-java.itheima.net/', // 要代理的地址
        changeOrigin: true // 是否跨域

      }
    }
    // before: require("./mock/mock-server.js")
  },

此时再重新npm run dev

 App running at:
  - Local:   http://localhost:8888/
  - Network: http://192.168.1.4:8888/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

 

 类似资料: