4

I have an uncommon webpack error and I don't know how to fix it..

It has something to do with my configuration, but I don't know what it is. A schoolmate of mine can perfectly run webpack in the console with the same project.

Earlier I got the error:

PS E:\HTL\Projects\EasyWater\Software\Beispielprojekte\WebPack_Dummy> webpack
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D

then I installed the Webpack CLI globally and now finally I get the error:

PS E:\HTL\Projects\EasyWater\Software\Beispielprojekte\WebPack_Dummy> webpack
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'loaders'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unk
nownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
   -> Options affecting the normal modules (`NormalModuleFactory`).

I have already reinstalled node js and literally everything, but I am continously get the same error.

As I said, my schoolmate can execute webpack with the same project.

I have installed:

  • ts-loader -g
  • webpack -g
  • webpack-cli -g
  • typescript -g
2
  • Did you even read what error states? What versions of webpack do you both have? Commented Mar 5, 2018 at 16:21
  • 1
    for webpack 4.1.0 and for webpack-cli 2.0.10 Commented Mar 5, 2018 at 17:30

2 Answers 2

1

I suspect your friend is not using webpack 4 and you are using a webpack.config.js configuration file incompatible with webpack 4. I myself am walking through a tutorial involving webpack and encountered the same error. By uninstalling webpack 4 in favor of webpack 3 (npm install webpack@3 --save-dev), I was able to run my npm build script of webpack --config webpack.config.js without issue and without the need for webpack-cli. An update to the configuration file may be more appropriate, but I am just starting out with webpack and this is the path of least resistance.

Sign up to request clarification or add additional context in comments.

2 Comments

My schoolmate have Version 3 of Webpack, I installed Webpack Version 3 and now I don't have to install the CLI anymore, but I still get the same error, which I mentioned above.
I use the same versions for everything, which my schoolmate has, now it works, thanks!
0

When using Webpack v4, change the 'loaders' option into 'rules' e.g

    module.exports = {
        entry: './your-entry-file',
        output: {
            ...                
          },
        module:{
           **rules**: [{ 
                  //rules replaces loaders
                  //all your configuration comes here
               }]
         }
    }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.