6
我正在尝试重写使用require.js来使用es6导入的旧应用程序。其中一个使用的库是Backbone和Underscore。要创建一个大包并将es6预编译为es5,我使用带有babel-loader的Webpack。 包被创建,但是当我在浏览器中加载它,我收到以下错误:与Webpack捆绑时,下划线给出错误
Uncaught TypeError: Cannot read property '_' of undefined
看来,“这个”在下划线中创建bundle.js未定义所以root._给我的错误。
// Baseline setup
// --------------
// Establish the root object, `window` in the browser, or `global` on the server.
var root = this;
// Save the previous value of the `_` variable.
var previousUnderscore = root._;
// Establish the object that gets returned to break out of a loop iteration.
var breaker = {}
有人遇到同样的问题?
你的'babel-loader' webpack配置是什么?您可能错过了'exclude:/ node_modules /'的行。 – loganfsmyth
Tnx很多!将'exclude:/ node_modules /'添加到'babel-loader' webpack config解决了这个问题! –