Javascript Webpack:Bundle.js-未捕获类型错误:(中间值)。setTimeout不是函数
这是我的webpack.config.jsJavascript Webpack:Bundle.js-未捕获类型错误:(中间值)。setTimeout不是函数,javascript,node.js,webpack,Javascript,Node.js,Webpack,这是我的webpack.config.js "use strict"; var webpack = require('webpack') module.exports = { entry: ['./main.js'], output: { path: __dirname, filename: 'bundle.js' }, module: { loaders: [ { test: /.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': {},
})
],
};
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';
和Main.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': {},
})
],
};
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插入到my 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)
uncaughttypeerror:(中间值)。setTimeout不是函数
at requestAnimationFrame(bundle.js:21935)
反对。(bundle.js:21941)
at\uuuuu网页包\uuuuuu需要(bundle.js:20)
反对。(bundle.js:21187)
at\uuuuu网页包\uuuuuu需要(bundle.js:20)
反对。(bundle.js:20136)
at\uuuuu网页包\uuuuuu需要(bundle.js:20)
反对。(bundle.js:19602)
at\uuuuu网页包\uuuuuu需要(bundle.js:20)
反对。(bundle.js:19553)
导致此错误的原因是什么?如何更改网页包配置以使其消失 我通过在webpack配置中将global定义为一个插件来解决这个问题,其中包含一个空输入
'global':{},
使用uglify()
例如:
.transform(babelify.configure({presets: ['@babel/preset-env']}))
.bundle() .pipe(source('app.js')) .pipe(buffer()) .pipe(uglify())
你的意思是在定义里?