Plugin/Preset files are not allowed to export objects,

相关文件

babel.config.js

module.exports = {
  presets: [
    '@vue/app',
    [
      "env",
      {
        "modules": false,
        "useBuiltIns": "entry"
      }
    ],
    "stage-0"
  ],
  "plugins": [
    ["import", {
      "libraryName": "iview",
      "libraryDirectory": "src/components"
    }],
    ["transform-runtime", {
      "corejs": false,
      "helpers": false,
      "polyfill": false,
      "regenerator": true,
      "moduleName": "babel-runtime"
    }]
  ],
  "comments": false
}

package.json

{
  "name": "housing_pc",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "vue": "^2.5.17",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.1.1",
    "@vue/cli-service": "^3.1.4",
    "axios": "^0.18.0",
    "babel-plugin-import": "^1.11.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-0": "^6.24.1",
    "babel-runtime": "^6.26.0",
    "iview": "^3.1.5",
    "node-sass": "^4.10.0",
    "sass-loader": "^7.1.0",
    "vue-template-compiler": "^2.5.17"
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

main.js

import "babel-polyfill"
import Vue from 'vue'
import App from './App.vue'
import router from './router/router'
import store from './vuex/store'
// import {
//   Carousel,
//   CarouselItem,
//   Select,
//   Option,
//   Input
// } from 'iview';
// import 'iview/dist/styles/iview.css';

// Vue.component('Carousel', Carousel);
// Vue.component('CarouselItem', CarouselItem);
// Vue.component('Select', Select);
// Vue.component('Option', Option);
// Vue.component('Input', Input);

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
vue -V
3.1.3

使用了iview做UI框架,但是ie会报错,

./node_modules/iview/src/utils/assist.js
SCRIPT1014: 无效字符

尝试使用babel,但是出现了

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In D:\miniapp\housing_pc\node_modules\babel-preset-stage-0\lib\index.js
    at createDescriptor (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-descriptors.js:178:11)
    at items.map (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
    at createPresetDescriptors (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-descriptors.js:101:10)
    at presets (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-descriptors.js:47:19)
    at mergeChainOpts (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-chain.js:320:26)
    at D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-chain.js:283:7
    at buildRootChain (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\config-chain.js:90:20)
    at loadPrivatePartialConfig (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\partial.js:85:55)
    at Object.loadPartialConfig (D:\miniapp\housing_pc\node_modules\@babel\core\lib\config\partial.js:110:18)
    at Object.<anonymous> (D:\miniapp\housing_pc\node_modules\babel-loader\lib\index.js:140:26)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (D:\miniapp\housing_pc\node_modules\babel-loader\lib\index.js:3:103)
    at _next (D:\miniapp\housing_pc\node_modules\babel-loader\lib\index.js:5:194)
    at D:\miniapp\housing_pc\node_modules\babel-loader\lib\index.js:5:364

 @ multi (webpack)-dev-server/client?http://192.168.0.152:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

有没有人知道这个应该怎么解决一下?

阅读 5.3k
2 个回答

vue本身就不支持IE,为何要去兼容IE呢??

楼主的 babel 配置是不是有点问题,相关依赖换成 @vue/cli-plugin-babel 这个试试看

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题