错误 vue.config.js 中的选项无效:不允许“baseUrl”

nam*_*org 0 vue.js vuejs3

user@host:/var/www/abc/def/frontend# npm run serve

> frontend@0.1.0 serve /var/www/abc/def/frontend
> vue-cli-service serve

 ERROR  Invalid options in vue.config.js: "baseUrl" is not allowed
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0 serve 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!     /root/.npm/_logs/2022-05-23T20_18_30_614Z-debug.log
Run Code Online (Sandbox Code Playgroud)

nam*_*org 5

这不是编码问题,问题是 vue ui 仍然在保存时将 baseUrl 添加到 vue 配置文件中,但它已被弃用并被 publicPath 取代。

因此,由于它已被弃用,vue cli 会通过其自己生成的文件创建错误^^。

通过更改 vue ui 以更新 vue 配置文件而publicPath不是baseUrl.

来源