Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid configuration object. Webpack has been initialised using a configuration

As of this morning, with Angular CLI 1.0.0-beta.14 I ng new try3 and ng serve and get the following error:

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?, plugins?, 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?, 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?, plugins?, mainFields?, aliasFields?, mainFiles?, extensions?, enforceExtension?, moduleExtensions?, enforceModuleExtension?, alias?, symlinks?, unsafeCache?, cachePredicate?, fileSystem?, 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) 

The last time I ng new a project was a few days ago -- at that point it worked file. Here's my environment:

angular-cli: 1.0.0-beta.14 node: 6.5.0 os: linux x64 
like image 687
Jan Nielsen Avatar asked Sep 20 '16 18:09

Jan Nielsen


People also ask

How do you fix invalid configuration object webpack has been initialized using a configuration object that does not match the API schema?

Webpack has been initialised using a configuration object that does not match the API schema Error First of all, just uninstall webpack with this command: npm uninstall webpack –save-dev Now, Reinstall webpack with this command: npm install webpack –save-dev I Hope, Your error should be solved now.

Where is webpack config JavaScript?

The webpack configuration file webpack. config. js is the file that contains all the configuration, plugins, loaders, etc. to build the JavaScript part of the NativeScript application. The file is located at the root of the NativeScript application.


2 Answers

Upgrade Angular CLI to 1.0.0-beta.15 or better:

  npm uninstall angular-cli -g   npm cache clean   npm install angular-cli@latest -g 

which generates working scaffolds:

  ng new try4   cd try4   ng serve 

If you have an existing project built with prior versions of Angular CLI, you will need to upgrade:

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

and carefully review each of the differences in each file.

Root cause: Once a version of Angular CLI is working, it should not stop working, of course. Unfortunately, angular-cli 1.0.0-beta.14 has a "caret" dependency on webpack: ^2.1.0-beta.22 -- note the ^. Yesterday, webpack released 2.1.0-beta.23 which is not compatible with angular-cli 1.0.0-beta.14 so, due to the caret (^), deployed versions of angular-cli 1.0.0-beta.14 have stopped working. To address this problem, angular-cli 1.0.0-beta.15 was released yesterday with a fixed webpack: 2.1.0-beta.22 dependency -- note the lack of the ^ -- thus avoiding the breaking upgrade to webpack. See https://github.com/angular/angular-cli/issues/2234 for details.

Project work-around: If you can't, or won't, upgrade Angular CLI, you can work-around the caret webpack dependency by adding a fixed webpack dependency to your own project. You'll have to maintain this dependency going forward, of course:

  npm install [email protected] --save-dev 

Choose this work-around if you can't upgrade Angular CLI.

like image 51
Jan Nielsen Avatar answered Oct 09 '22 13:10

Jan Nielsen


I just ran into this issue today running an ng2.0.0 project the solution was to downgrade webpack.

npm uninstall webpack --save-dev  npm install [email protected] --save-dev 

this will probably be fixed soon on the package.json that angular-cli 1.0.0-beta.15 generates.

this fix should resolve the issue on any existing projects.

like image 33
theRemix Avatar answered Oct 09 '22 15:10

theRemix