首页 > 解决方案 > 未捕获的 TypeError:[] 不是函数

问题描述

我正在使用 vue js 2.6.10,就在我在 npm 上更新我的所有包之后,我的应用程序在生产环境中根本无法运行......它在开发环境中运行良好

错误是

Uncaught TypeError: [] is not a function

当我检查来源时,错误来自这个

), [], !1, null, null, null).exports
      , va = []((function() {
        if ("undefined" != typeof document) {
            var t = document.head || document.getElementsByTagName("head")[0]
              , e = document.createElement("style")
              , a = " a[data-v-11b2e33f] { cursor: pointer; } ";
            e.type = "text/css",
            e.styleSheet ? e.styleSheet.cssText = a : e.appendChild(document.createTextNode(a)),
            t.appendChild(e)
        }
    }

我不知道这是什么意思。我尝试进行 npm install 和 npm update 以确保所有内容都相应更新但仍然没有运气

这是我的 vue 应用程序 package.json (也许这会有所帮助)

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.19.0",
        "bootstrap": "^4.4.1",
        "cross-env": "^5.2.1",
        "jquery": "^3.4.1",
        "laravel-mix": "^5.0.0",
        "lodash": "^4.17.15",
        "popper.js": "^1.16.0",
        "resolve-url-loader": "^3.1.1",
        "sass": "^1.23.7",
        "sass-loader": "^8.0.0",
        "vue": "^2.6.10",
        "vue-template-compiler": "^2.6.10"
    },
    "dependencies": {
        "@ckeditor/ckeditor5-build-classic": "^15.0.0",
        "echarts": "^4.5.0",
        "fibers": "^4.0.2",
        "file-saver": "^2.0.2",
        "hooper": "^0.3.4",
        "katex": "^0.10.2",
        "laravel-vue-pagination": "^2.3.1",
        "moment": "^2.24.0",
        "node-sass": "^4.13.0",
        "v-tooltip": "^2.0.2",
        "vee-validate": "^2.2.15",
        "vue-ckeditor5": "^0.4.1",
        "vue-cleave-component": "^2.1.3",
        "vue-context-menu": "^2.0.6",
        "vue-echarts": "^4.0.4",
        "vue-echarts-v3": "^2.0.1",
        "vue-json-excel": "^0.2.98",
        "vue-katex": "^0.3.0",
        "vue-router": "^3.1.3",
        "vue-truncate-collapsed": "^2.1.0",
        "vue2-filters": "^0.8.0",
        "vuex": "^3.1.2"
    }
}

标签: javascriptvue.jsnpm

解决方案


), [], !1, null, null, null).exports
      , va = []((function() {
        if ("undefined" != typeof document) {
            var t = document.head || document.getElementsByTagName("head")[0]
              , e = document.createElement("style")
              , a = " a[data-v-11b2e33f] { cursor: pointer; } ";
            e.type = "text/css",
            e.styleSheet ? e.styleSheet.cssText = a : e.appendChild(document.createTextNode(a)),
            t.appendChild(e)
        }
    }

我认为第 2 行有问题。你不应该有任何声明 after [],所以你应该在之后添加换行符[]

像这样的东西

va = [];((function() {
...

推荐阅读