'I get webpack not installed, but webpack --version finds webpack

I am following this tutorial to create a React project with webpack. Everything went smooth until step 4 webpack --config webpack.config.js, where I get this error:

webpack not installed

Install webpack to start bundling: 
  $ npm install --save-dev webpack

But if I type webpack --version, I get 4.43.0.

I don't know what is wrong.



Solution 1:[1]

Based on the information you gave, your webpack.config.js might be invalid, e.g., importing missing module, or not exporting proper configuration.

See this issue for more context: https://github.com/webpack/webpack/issues/9242#issuecomment-500350448

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zzz