gpt4 book ai didi

javascript - Webpack:Bundle.js - 未捕获的类型错误:(中间值).setTimeout 不是函数

转载 作者:行者123 更新时间:2023-11-30 15:37:11 26 4
gpt4 key购买 nike

这是我的 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 中。然后浏览器报错:

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 定义为一个插件来解决它,输入为空。

'全局': {},

关于javascript - Webpack:Bundle.js - 未捕获的类型错误:(中间值).setTimeout 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41359987/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com