Tag Archives: View / cli

[Solved] Vue/cli install element error: Error: cannot find module ‘Babel plugin component’

Use the elementui component library to introduce elementui as needed. Configure the error according to the code in the official document!!

Error: cannot find module ‘Babel plugin component’

fisrt install babel-plugin-component:  

npm install babel-plugin-component -D

vue/cli   There is no.Babelrc file, but babel.config.js file. When importing on demand, you need to configure it in babel.config.js file

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
  ],
  plugins: [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
};