angular2 – 无效的配置对象 Webpack已使用配置进行初始化

前端之家收集整理的这篇文章主要介绍了angular2 – 无效的配置对象 Webpack已使用配置进行初始化前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
截至今天上午,使用Angular CLI 1.0.0-beta.14的新的try3和ng服务,并得到以下错误
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'tslint'. These properties are valid:
   object { amd?,bail?,cache?,context?,devServer?,devtool?,entry,externals?,loader?,module?,name?,dependencies?,node?,output?,plugins?,profile?,recordsInputPath?,recordsOutputPath?,recordsPath?,resolve?,resolveLoader?,stats?,target?,watch?,watchOptions? }
 - configuration.module has an unknown property 'preLoaders'. These properties are valid:
   object { rules?,loaders?,noParse?,unknownContextRequest?,unknownContextRegExp?,unknownContextRecursive?,unknownContextCritical?,exprContextRequest?,exprContextRegExp?,exprContextRecursive?,exprContextCritical?,wrappedContextRegExp?,wrappedContextRecursive?,wrappedContextCritical? }
   Options affecting the normal modules (`NormalModuleFactory`).
 - configuration.node.global should be a boolean.
 - configuration.resolve has an unknown property 'root'. These properties are valid:
   object { modules?,descriptionFiles?,mainFields?,aliasFields?,mainFiles?,extensions?,enforceExtension?,moduleExtensions?,enforceModuleExtension?,alias?,symlinks?,unsafeCache?,cachePredicate?,fileSystem?,resolver? }
 - configuration.resolve.extensions[0] should not be empty.
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'tslint'. These properties are valid:
   object { amd?,resolver? }
 - configuration.resolve.extensions[0] should not be empty.
    at webpack (/home/jan/src/fm-repos/try3/node_modules/webpack/lib/webpack.js:16:9)
    at Class.run (/home/jan/src/fm-repos/try3/node_modules/angular-cli/tasks/serve-webpack.js:23:27)
    at /home/jan/src/fm-repos/try3/node_modules/angular-cli/commands/serve.js:84:26
    at process._tickCallback (internal/process/next_tick.js:103:7)

最后一次我新的项目是几天前 – 那时它工作文件。这里是我的环境:

angular-cli: 1.0.0-beta.14
node: 6.5.0
os: linux x64
将Angular CLI升级到1.0.0-beta.15或更高版本:
npm uninstall angular-cli -g
  npm cache clean
  npm install angular-cli@latest -g

其产生工作支架:

ng new try4
  cd try4
  ng serve

如果您有现有项目使用以前版本的Angular CLI构建,您将需要升级

rm -rf node_modules dist tmp
  npm install angular-cli@latest --save-dev
  ng init

并仔细检查每个文件中的每个差异。

根本原因:一旦一个版本的Angular CLI正在工作,它不应该停止工作,当然。不幸的是,angular-cli 1.0.0-beta.14对webpack有一个“caret”依赖:^ 2.1.0-beta.22 – 注意^。昨天,webpack发布了2.1.0-beta.23,这与angular-cli 1.0.0-beta.14不兼容,所以,由于插入符号(^),已部署的angular-cli 1.0.0-beta.14版本停止工作。为了解决这个问题,angular-cli 1.0.0-beta.15昨天发布了一个固定的webpack:2.1.0-beta.22依赖 – 注意缺少^ – 从而避免了breakpack升级到webpack。详情请参见https://github.com/angular/angular-cli/issues/2234

项目解决方案:如果您不能或不会升级Angular CLI,您可以通过向您自己的项目添加一个固定的webpack依赖关系来解决插入符webpack依赖关系。你必须保持这种依赖性,当然:

npm install webpack@2.1.0-beta.22 --save-dev

如果您无法升级Angular CLI,请选择此解决方法

原文链接:https://www.f2er.com/angularjs/145194.html

猜你在找的Angularjs相关文章