Webpack迁移问题

时间:2018-06-18 15:24:40

标签: angular webpack webpack-2

我正在尝试将我的Angular应用程序升级到Webpack 3,并且我的webpack配置文件中有以下节点对象:

module.exports {

  node: {
  fs: 'empty',
global: 'true',
crypto: 'empty',
process: false,
module: false,
clearImmediate: false,
setImmediate: false
}

}

我一直收到以下错误:

 Invalid configuration object. Webpack has been initialised using a 
configuration object that does not match the API schema.
 - configuration.node should be one of these:
  false | object { Buffer?, __dirname?, __filename?, console?, global?, 
process?, ... }
 -> Include polyfills or mocks for various node stuff.
Details:
* configuration.node should be false
* configuration.node.global should be a boolean.
  -> Include a polyfill for the 'global' variable

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

node.global

错误中包含的上述消息表明配置中global: 'true'的值类型不正确。

更改您的配置,使global: true代替true {注意没有引号,这意味着值现在是布尔值'true',而不是字符串module.exports = { //... node: { fs: 'empty', global: true, \\ <-- quotes removed crypto: 'empty', process: false, module: false, clearImmediate: false, setImmediate: false } }

{{1}}