vue added error to the UI library when starting the project when loading on demand babel-preset-es2015 error

The project is built using the vue cli3 scaffolding tool
as shown in the official element documentation.

npm install babel-plugin-component -D

Then add the .babelrc file

{
  "presets": [["es2015", { "modules": false }]],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

Report an error:

Error: Cannot find module 'babel-preset-es2015' from

Solution:

1. Install @ babel / preset-env; run the command line in the project directory

npm i @babel/preset-env -D

2. Modify the .babelrc file and change es2015 to @ babel / preset-env

{
  "presets": [["@babel/preset-env", { "modules": false }]],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

 

Guess you like

Origin www.cnblogs.com/caoleyun/p/12727609.html