Tag: angular webpack starter

Webpack添加jQuery插件:错误:jQuery需要一个带文档的窗口

我正在使用Angular 4 + webpack。我在webpack.config.vendor.js中向nonTreeShakableModules const添加了一个jQuery插件: const path = require(‘path’); const webpack = require(‘webpack’); const ExtractTextPlugin = require(‘extract-text-webpack-plugin’); const merge = require(‘webpack-merge’); const treeShakableModules = [ ‘@angular/animations’, ‘@angular/common’, ‘@angular/compiler’, ‘@angular/core’, ‘@angular/forms’, ‘@angular/http’, ‘@angular/platform-browser’, ‘@angular/platform-browser-dynamic’, ‘@angular/router’, ‘font-awesome/css/font-awesome.css’, ‘zone.js’, ]; const nonTreeShakableModules = [ ‘bootstrap’, ‘bootstrap/dist/css/bootstrap.css’, ‘es6-promise’, ‘es6-shim’, ‘event-source-polyfill’, ‘jquery’, ‘virtual-keyboard’ //HERE ]; 启动应用程序时出现此错误: NodeInvocationException:由于错误,Prerendering失败:错误: jQuery需要一个带文档的窗口 如果我刷新页面2-3次,则错误消失。 谢谢你的帮助!