2016-12-28 49 views
0

這裏是我的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配置使它走嗎?

回答

1

我通過將webpack配置中的全局定義爲一個插件,並使用空輸入來解決此問題。

'global': {},

相關問題