Vue Cli 3生产构建失败,而开发构建正常

时间:2019-02-07 11:06:23

标签: javascript vue.js production

我有一个要部署的VueCLI 3支架式VueJS应用程序。使用npm run serve运行的开发版本运行良好,并且一切运行正常。但是在先运行npm run build然后运行serve -s dist时,出现了很多错误。其中一些错误是:

Error: "Unable to find required dependency e"
TypeError: "this.userDataStorage is undefined"
TypeError: "this.user is undefined
Unhandled promise rejection TypeError: "t.auth is undefined"

这就像生成的dist包可能丢失了某些东西,而我不知道发生了什么问题或可能丢失了什么。任何帮助解除此问题的帮助将不胜感激。也许是一种依赖(例如vue-inject,我用作IoC框架)可能是罪魁祸首?

分别是我的packages.jsonvue.config.js

{
  "name": "myapp",
  "description": "",
  "keywords": [],
  "version": "0.1.0",
  "dependencies": {
    "bootstrap": "3.3.2",
    "d3": "^5.7.0",
    "d3-gantt-chart": "^0.2.8",
    "d3-layout-timeline": "^1.0.3",
    "d3-transition": "^1.1.1",
    "d3plus-text": "^0.9.32",
    "foundation-sites": "^6.5.0-rc.3",
    "jquery": "^3.3.1",
    "jquery-ui": "^1.12.1",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.11",
    "tinycolor": "latest",
    "underscore": "^1.9.1",
    "vue": "^2.5.17",
    "vue-formio": "^3.0.1",
    "vue-inject": "^2.1.1",
    "vue-router": "^3.0.1",
    "vue-slider-component": "^2.8.0",
    "vuejs-datepicker": "^1.5.3",
    "vuex": "^3.1.0",
    "what-input": "^5.1.2"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.3.0",
    "@vue/cli-plugin-e2e-nightwatch": "^3.3.0",
    "@vue/cli-plugin-eslint": "^3.3.0",
    "@vue/cli-plugin-unit-jest": "^3.3.0",
    "@vue/cli-service": "^3.3.1",
    "@vue/eslint-config-prettier": "^4.0.1",
    "@vue/test-utils": "^1.0.0-beta.28",
    "ajv": "^6.5.3",
    "axios": "^0.18.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "babel-runtime": "^6.26.0",
    "bootstrap-sass": "^3.3.7",
    "css-loader": "^1.0.1",
    "eslint": "^5.12.1",
    "eslint-config-prettier": "^3.6.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-html": "^5.0.0",
    "eslint-plugin-import": "^2.15.0",
    "eslint-plugin-node": "^8.0.1",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^5.1.0",
    "husky": "^1.3.1",
    "lint-staged": "^8.1.0",
    "node-sass": "^4.11.0",
    "sass-loader": "^7.1.0",
    "script-loader": "^0.7.2",
    "stylelint": "^9.10.1",
    "stylelint-config-sass-guidelines": "^5.3.0",
    "stylelint-config-standard": "^18.2.0",
    "vue-drag-drop": "^1.1.4",
    "vue-hot-reload-api": "^2.3.0",
    "vue-template-compiler": "^2.5.17",
    "vue2-dropzone": "^3.5.2"
  },
  "author": "devops@myapp.io",
  "contributors": [],
  "license": "Unlicense",
  "readmeFilename": "Readme.md",
  "repository": {
    "type": "git",
    "url": ""
  },
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:e2e": "vue-cli-service test:e2e",
    "test:unit": "vue-cli-service test:unit"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.js": [
      "vue-cli-service lint",
      "git add"
    ],
    "*.vue": [
      "vue-cli-service lint",
      "git add"
    ],
    "*.css": [
      "stylelint --fix",
      "git add"
    ],
    "*.scss": [
      "stylelint --syntax=scss",
      "git add"
    ]
  }
}
var webpack = require("webpack");
var path = require("path");

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        jquery: "jquery"
      })
    ],
    resolve: {
      extensions: [".js", ".vue", ".json"],
      alias: {
        jquery: "jquery/src/jquery.js",
        "jquery-ui": "jquery-ui",
        d3: "d3",
        modules: path.join(__dirname, "node_modules")
      }
    }
  }
};

0 个答案:

没有答案