其他分享
首页 > 其他分享> > Couldn't find preset "es2015" relative to directory

Couldn't find preset "es2015" relative to directory

作者:互联网

在引入element-ui引发的问题,解决如下:

  1.npm install babel-preset-es2015 --save-dev

  2.修改.babelrc 

    

{
  "presets": [
    ["es2015", { "modules": false }],
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": [
    "transform-vue-jsx",
    "transform-runtime",
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ],
  "env": {
    "test": {
      "presets": ["env", "stage-2"]
    }
  }
}

  3.在webpack.base.conf.js文件中加入如下代码:

  

loaders: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['es2015']
        }
      }
    ]

 

 

标签:false,Couldn,env,babel,presets,modules,relative,preset,es2015
来源: https://www.cnblogs.com/lude1994/p/12004642.html