在前端开发的时候,启动运行Vue项目的时候:npm run dev或者 npm run start 或者yarn examples:start,遇到ValidationError:webpack Dev Server Invalid Options报错的提示,报错信息如下所示:
Cheng$ npm run start
> tenant@0.1.0 start /Users/Cheng/hnant
> vue-cli-service serve
INFO Starting development server...
WARN A new version of sass-loader is available. Please upgrade for best experience.
ERROR ValidationError: webpack Dev Server Invalid Options
options.proxy should be {Object|Array} (https://webpack.js.org/configuration/dev-server/#devserverproxy)
ValidationError: webpack Dev Server Invalid Options
options.proxy should be {Object|Array} (https://webpack.js.org/configuration/dev-server/#devserverproxy)
at validateOptions (/Users/Cheng/hnant/node_modules/_schema-utils@1.0.0@schema-utils/src/validateOptions.js:32:11)
at new Server (/Users/Cheng/hnant/node_modules/_webpack-dev-server@3.11.2@webpack-dev-server/lib/Server.js:57:5)
at serve (/Users/Cheng/hnant/node_modules/_@vue_cli-service@4.5.11@@vue/cli-service/lib/commands/serve.js:172:20)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tenant@0.1.0 start: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tenant@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Cheng/.npm/_logs/2021-03-01T01_05_47_996Z-debug.log
引起上述问题的原因是:项目配置文件config.js里面用来解决跨域问题的代理proxy里面是空的,然后引起上述报错问题。
解决上述问题的方法步骤也不复杂,直接找到项目工程里面的config.js文件,然后找到module.exports里面的devServer的proxy,
然后直接注释或者删除proxy,
然后保存该文件,最后重新运行项目即可解决上述问题。
以上就是本章全部内容,欢迎关注三掌柜的微信公众号“程序猿by三掌柜”,三掌柜的新浪微博“三掌柜666”,欢迎关注!
三掌柜的微信公众号:
三掌柜的新浪微博: