Webpack: Bundle.js - Uncaught TypeError: (intermediate value).setTimeout 不是函数 [英] Webpack: Bundle.js - Uncaught TypeError: (intermediate value).setTimeout is not a function
本文介绍了Webpack: Bundle.js - Uncaught TypeError: (intermediate value).setTimeout 不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的 webpack.config.js
"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 中.然后浏览器给出错误:
The Bundle.js is inserted in my Index.html. The browser then gives the error:
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 配置以使其消失?
What is the cause of this error, and how could I change the webpack config to make it go away?
推荐答案
我通过在 webpack 配置中将 global 定义为插件来解决它,输入为空.
I solved it by defining global in the webpack config as a plugin, with an empty input.
'全局':{},
这篇关于Webpack: Bundle.js - Uncaught TypeError: (intermediate value).setTimeout 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文