ERROR in ./src/main.js Module build failed (from ./node_modules/babel-loader/lib/index.js): TypeError: E:\webs\test\src\main.js: Cannot read property 'bindings' of null at Scope.moveBindingTo (E:\webs\test\node_modules\@babel\traverse\lib\scope\index.js:929:13) at BlockScoping.updateScopeInfo (E:\webs\test\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:364:17) at BlockScoping.run (E:\webs\test\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:330:12) at PluginPass.BlockStatementSwitchStatementProgram (E:\webs\test\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:70:24) at newFn (E:\webs\test\node_modules\@babel\traverse\lib\visitors.js:175:21) at NodePath._call (E:\webs\test\node_modules\@babel\traverse\lib\path\context.js:55:20) at NodePath.call (E:\webs\test\node_modules\@babel\traverse\lib\path\context.js:42:17) at NodePath.visit (E:\webs\test\node_modules\@babel\traverse\lib\path\context.js:92:31) at TraversalContext.visitQueue (E:\webs\test\node_modules\@babel\traverse\lib\context.js:112:16) at TraversalContext.visitSingle (E:\webs\test\node_modules\@babel\traverse\lib\context.js:84:19) at TraversalContext.visit (E:\webs\test\node_modules\@babel\traverse\lib\context.js:140:19) at Function.traverse.node (E:\webs\test\node_modules\@babel\traverse\lib\index.js:82:17) at traverse (E:\webs\test\node_modules\@babel\traverse\lib\index.js:64:12) at transformFile (E:\webs\test\node_modules\@babel\core\lib\transformation\index.js:107:29) at transformFile.next (<anonymous>) at run (E:\webs\test\node_modules\@babel\core\lib\transformation\index.js:35:12) at run.next (<anonymous>) at Function.transform (E:\webs\test\node_modules\@babel\core\lib\transform.js:27:41) at transform.next (<anonymous>) at E:\webs\test\node_modules\gensync\index.js:266:13 at async.call.result.err.err (E:\webs\test\node_modules\gensync\index.js:216:11) at E:\webs\test\node_modules\gensync\index.js:184:28 at E:\webs\test\node_modules\@babel\core\lib\gensync-utils\async.js:72:7 at E:\webs\test\node_modules\gensync\index.js:108:33 at step (E:\webs\test\node_modules\gensync\index.js:280:14) at E:\webs\test\node_modules\gensync\index.js:266:13 at async.call.result.err.err (E:\webs\test\node_modules\gensync\index.js:216:11)
webpack是4.2X的,改成这样就好了
module: { rules: [ { test: /\.js$/, loader: 'babel-loader', exclude: path.join(__dirname, '/node_modules/'), include: path.join(__dirname, 'src') }] }