You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从@vue/cli-service引入defineConfig时提示undefined报错

问题结论

defineConfig 是 仅@vue/cli 5.x及以上版本 才在@vue/cli-service中对外导出的工具方法。你当前使用的@vue/cli 4.5.15版本未提供该API,因此导入得到的defineConfig值为undefined,调用时抛出TypeError: defineConfig is not a function异常。

可选解决方案
  • 方案一:保留现有@vue/cli 4.5.15版本
    不需要使用defineConfig包裹配置,直接导出普通配置对象即可,修改后的vue.config.js代码如下:
    module.exports = {
      devServer: {
        port: 3001,
      },
    };
    
  • 方案二:使用defineConfig能力
    将项目的@vue/cli相关依赖升级到5.x版本,升级完成后原有defineConfig写法可直接正常运行,无需额外调整配置逻辑。

内容的提问来源于stack exchange,提问作者elBrambore

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 06:57:15