的WebPack:Bundle.js - 遗漏的类型错误:(中间值).setTimeout不是一个函数
问题描述:
这里是我的webpack.config.js的WebPack:Bundle.js - 遗漏的类型错误:(中间值).setTimeout不是一个函数
"use strict";
var webpack = require('webpack')
module.exports = {
entry: ['./main.js'],
output: { path: __dirname, filename: 'bundle.js' },
module: {
loaders: [
{
test: /.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
{test: /\.json$/, loader: "json"},
]
},
externals: {
React: 'react',
},
target: "node",
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
'global': {},
})
],
};
而且Main.js
import React from 'react';
import ReactDOM from 'react-dom';
import {Table, Column, Cell} from 'fixed-data-table';
import Chart from 'chartjs';
import jQuery from 'jquery';
import vis from 'vis';
import babel from 'babel-core';
将Bundle.js插入到我的Index.html中。然后浏览器给出了错误:
Uncaught TypeError: (intermediate value).setTimeout is not a function
at requestAnimationFrame (bundle.js:21935)
at Object.<anonymous> (bundle.js:21941)
at __webpack_require__ (bundle.js:20)
at Object.<anonymous> (bundle.js:21187)
at __webpack_require__ (bundle.js:20)
at Object.<anonymous> (bundle.js:20136)
at __webpack_require__ (bundle.js:20)
at Object.<anonymous> (bundle.js:19602)
at __webpack_require__ (bundle.js:20)
at Object.<anonymous> (bundle.js:19553)
这是什么错误的原因,以及如何可以改变的WebPack配置使它走吗?
答
我通过将webpack配置中的全局定义为一个插件,并使用空输入来解决此问题。
'global': {},