Published on

webpackでのCompiled with problems:X WARNING configurationの対応方法

Authors
  • avatar
    Name
    ssu
    Twitter

webpack-dev-serverでサーバを立ち上げたときに、下記のようにエラーが出たので、 その対応方法を紹介します。

Compiled with problems:X WARNING configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

The 'mode' option has not been set, webpack will fallback to 'production' for this value.Set 'mode' option to 'development' or 'production' to enable defaults for each environment.

エラーに書いてある通りで、modeでdevelopmentかproductionかを指定していないのが問題です。 そのため、pakcage.jsonで下記のようにmodeを指定してあげれば解決できます。

"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "webpack": "webpack --watch", "dev": "webpack-dev-server --mode development" },

参考: https://webpack.js.org/configuration/mode/