vue 编译提示安装 core-js,很有可能是这个错:

WARNING: We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.

You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:

  npm install --save core-js@2    npm install --save core-js@3
  yarn add core-js@2              yarn add core-js@3


解决方案:

.babelrc

{
  "presets": [
    [
      "@babel/env",
      {
        "targets": {
          "chrome": "58",
          "ie": "10"
        },
        "useBuiltIns": "usage",
        "corejs": "2"  //主要就是这里, 写2 或者 3 根据你安装的版本

      }
    ]
  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-proposal-object-rest-spread",
    "transform-vue-jsx",
    ["component", {
      "libraryName": "mint-ui",
      "style": true
    }]
  ]
}

package.json

"devDependencies": {
    "@babel/core": "^7.6.4",
    "@babel/plugin-transform-runtime": "^7.6.2",
    "@babel/preset-env": "^7.6.3",
    "babel-core": "^7.0.0-bridge.0",
    "babel-loader": "^7.1.5",
    "babel-plugin-component": "^1.1.1",
    "babel-preset-es2015-node6": "^0.4.0",
    "clean-webpack-plugin": "^0.1.17",
    "clipboard-polyfill": "^2.8.6",
    "copy-webpack-plugin": "^4.5.2",
    "cross-env": "^5.2.0",
    "css-loader": "^0.28.8",
    "eslint-config-prettier": "^6.0.0",
    "eslint-plugin-prettier": "^3.1.0",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "file-loader": "^1.1.11",
    "glob": "^7.1.2",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.0.6",
    "jquery": "^2.2.4",
    "less": "^3.9.0",
    "less-loader": "^4.1.0",
    "node-sass": "^4.11.0",
    "open": "^0.0.5",
    "postcss": "^7.0.2",
    "postcss-loader": "^2.1.5",
    "postcss-preset-env": "^5.2.1",
    "postcss-short": "^4.1.0",
    "postcss-sorting": "^3.1.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.7",
    "shelljs": "^0.8.2",
    "style-loader": "^0.20.3",
    "url-loader": "^1.1.2",
    "vue-loader": "^14.0.3",
    "vue-router": "^3.0.2",
    "vue-template-compiler": "^2.5.16",
    "vue-touch": "^2.0.0-beta.4",
    "webpack": "^4.2.0",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.1.1",
    "webpack-merge": "^4.1.3",
    "webpack-spritesmith": "^0.4.1"
  },
  "dependencies": {
    "@babel/polyfill": "^7.6.0",
    "@babel/runtime": "^7.6.3",
    "autoprefixer": "^9.5.0",
    "axios": "^0.18.0",
    "babel-plugin-transform-vue-jsx": "^3.7.0",
    "core-js": "^2.6.10",  //  根据这里选择 上面core 的版本
    "eslint": "^5.0.0",
    "eslint-plugin-vue": "^5.2.3",
    "fundebug-javascript": "^2.0.0",
    "fundebug-revideo": "^0.6.0",
    "fundebug-vue": "0.0.1",
    "mint-ui": "^2.2.13",
    "qrcode": "^1.4.1",
    "regenerator-runtime": "^0.13.3",
    "styled-jsx": "^3.2.2",
    "swiper": "^4.5.0",
    "typescript": "^3.5.2",
    "underscore": "^1.9.1",
    "vue": "^2.5.16",
    "vue-awesome-swiper": "^3.1.3",
    "vue-baberrage": "^2.1.9",
    "vue-lazyload": "^1.3.3",
    "vue-resource": "^1.5.1",
    "vuex": "^3.1.0"
  },
Logo

前往低代码交流专区

更多推荐