VUE3 TypeError: defineConfig is not a function
1. 问题
在运行npm run serve时,出现报错:
![defineConfig is not a function](https://i-blog.csdnimg.cn/blog_migrate/4b75c9f827247125a8a6c59848bda161.png)
2. 原因
原因:由于用vue-cli直接创建了vue 3的项目,而里面的生态并非都是最新版,vue.config.js中的代码如下,使用了vue 3的语法。
vue.config.js中的代码如下:
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})
3. 解决
输入命令 vue upgrade
,一直yes,即可解决