Home > Mobile >  defineConfig is undefined when required from @vue/cli-service - vue.config.js
defineConfig is undefined when required from @vue/cli-service - vue.config.js

Time:06-18

I'm trying to set up my vue.config.js file and found that issue when I use defineConfig method from @vue/cli-service.

TypeError: defineConfig is not a function

vue.config.js

const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  devServer: {
    port: 3001,
  },
});

defineConfig is undefined. I was trying to look for it in cli-service folder, but (as suppose) there is no such method.

I'm using vue.js 3, yarn 1.22.17 and my @vue/cli version is 4.5.15. Is it possible that defineConfig is for @vue/cli version 5..?

CodePudding user response:

defineConfig macro is used by Vite not by Vue CLI, the right syntax for vue cli :

module.exports = {
  devServer: {
    port: 3001,
  },
};
  • Related