在升级packaje.json条目时获取WebpackOptionsValidationError

时间:2017-04-05 12:17:40

标签: angular webpack

我手动更新了package.json中的angular libraries和webpack。现在,当我运行应用程序时,我得到以下错误:

System.Exception: Call to Node module failed with error: WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve.extensions[0] should not be empty.
    at webpack (C:\FoodPortal.Intertek.Project\FoodPortal.Intertek\FoodPortal.Intertek\node_modules\webpack\lib\webpack.js:19:9)
    at attachWebpackDevMiddleware (C:\FoodPortal.Intertek.Project\FoodPortal.Intertek\FoodPortal.Intertek\node_modules\aspnet-webpack\WebpackDevMiddleware.js:66:20)
    at C:\FoodPortal.Intertek.Project\FoodPortal.Intertek\FoodPortal.Intertek\node_modules\aspnet-webpack\WebpackDevMiddleware.js:217:21
    at Array.forEach (native)
    at Server.<anonymous> (C:\FoodPortal.Intertek.Project\FoodPortal.Intertek\FoodPortal.Intertek\node_modules\aspnet-webpack\WebpackDevMiddleware.js:192:32)
    at Server.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Server.emit (events.js:185:7)
    at emitListeningNT (net.js:1285:10)
    at _combinedTickCallback (internal/process/next_tick.js:71:11)

1 个答案:

答案 0 :(得分:0)

你在resolve.extensions中使用了一个空字符串,这在webpack 2中不再允许或不需要。

而不是:

resolve: {
  extensions: ['', '.js', '.json']
}

你只需要:

resolve: {
  extensions: ['.js', '.json']
}

升级到webpack时,您需要修改其他重大更改2.阅读官方Migration Guide,了解您需要更改的内容。