Webpack Babel-模块构建失败:TypeError:无法读取nul的属性“ bindings”

时间:2018-08-24 21:32:13

标签: vue.js webpack babel

我正在VUEJS 2中构建一个新项目,并且遇到了问题。我对Webpack相当陌生,所以我正在学习。您能告诉我为什么这段代码会引发错误吗?

  

./ store / modules / user / store.js

const state = {
    user: {}
};

然后,当它被编译时,webpack会抛出以下错误:

ERROR  Failed to compile with 1 errors                                                                         14:21:50
 error  in ./assets/js/store/modules/user/store.js

Module build failed: TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo (c:\myProject\node_modules\@babel\traverse\lib\scope\index.js:978:13)
    at BlockScoping.updateScopeInfo (c:\myProject\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:364:17)
    at BlockScoping.run (c:\myProject\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:330:12)
    at PluginPass.BlockStatementSwitchStatementProgram (c:\myProject\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:70:24)
    at newFn (c:\myProject\node_modules\@babel\traverse\lib\visitors.js:237:21)
    at NodePath._call (c:\myProject\node_modules\@babel\traverse\lib\path\context.js:65:20)
    at NodePath.call (c:\myProject\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (c:\myProject\node_modules\@babel\traverse\lib\path\context.js:100:12)
    at TraversalContext.visitQueue (c:\myProject\node_modules\@babel\traverse\lib\context.js:142:16)
    at TraversalContext.visitSingle (c:\myProject\node_modules\@babel\traverse\lib\context.js:102:19)
    at TraversalContext.visit (c:\myProject\node_modules\@babel\traverse\lib\context.js:182:19)
    at Function.traverse.node (c:\myProject\node_modules\@babel\traverse\lib\index.js:106:17)
    at traverse (c:\myProject\node_modules\@babel\traverse\lib\index.js:76:12)
    at transformFile (c:\myProject\node_modules\@babel\core\lib\transformation\index.js:116:29)
    at runSync (c:\myProject\node_modules\@babel\core\lib\transformation\index.js:45:3)
    at runAsync (c:\myProject\node_modules\@babel\core\lib\transformation\index.js:35:14)
    at process.nextTick (c:\myProject\node_modules\@babel\core\lib\transform.js:34:34)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

 @ ./assets/js/store/store.js 3:0-40
 @ ./assets/js/main.js
  

这是我的package.json

{
    "devDependencies": {
        "@symfony/webpack-encore": "^0.17.0",
        "@vue/cli-plugin-babel": "^3.0.0-rc.3",
        "@vue/test-utils": "^1.0.0-beta.20",
        "babel-core": "^7.0.0-bridge.0",
        "babel-jest": "^23.2.0",
        "node-sass": "^4.9.0",
        "sass-loader": "^7.0.3",
        "vue-loader": "^14.1.1",
        "vue-template-compiler": "^2.5.16"
    },
    "license": "UNLICENSED",
    "private": true,
    "scripts": {
        "dev-server": "encore dev-server",
        "dev": "encore dev",
        "watch": "encore dev --watch",
        "build": "encore production"
    },
    "dependencies": {
        "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.51",
        "@coreui/coreui": "^2.0.3",
        "@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.2.0",
        "@coreui/icons": "0.2.0",
        "@coreui/vue": "^2.0.0-rc.0",
        "axios": "^0.18.0",
        "bootstrap": "^4.1.1",
        "bootstrap-vue": "^2.0.0-rc.11",
        "chart.js": "^2.7.2",
        "core-js": "^2.5.7",
        "css-vars-ponyfill": "^1.7.2",
        "flag-icon-css": "^3.0.0",
        "font-awesome": "^4.7.0",
        "jquery": "^3.3.1",
        "npm": "^6.4.0",
        "perfect-scrollbar": "^1.4.0",
        "simple-line-icons": "^2.4.1",
        "sweetalert2": "^7.26.11",
        "vue": "^2.5.16",
        "vue-chartjs": "^3.3.2",
        "vue-perfect-scrollbar": "^0.1.0",
        "vue-router": "^3.0.1",
        "vue-table-component": "^2.0.0-alpha.1",
        "vue-tables": "^1.6.44",
        "vuetable": "^1.5.12",
        "vuex": "^3.0.1"
    }
}

我假设我缺少某种babel扩展名。我做了一些研究,认为这可能与es2015在“ store.js”文件中未被理解有关。关于我可以做些什么的任何想法?我还注意到我没有.babelrc文件,我需要在其中添加一些内容,这样才能正常工作吗?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我现在仅通过恢复为react-native@0.55.4进行了修复,使用(react-native@0.56)@ babel / core 7.0.0-beta时也遇到了错误。