LoginSignup
32
24

More than 3 years have passed since last update.

webpackをv3からv4にしたらwebpack.config.jsで怒られた

Last updated at Posted at 2017-08-22

webpackがエラーを吐いたのでその原因と修正について。
結論から言うと、webpackのバージョンによってwebpack.config.jsの記述方法が異なっていたことが原因でした。

エラー

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve has an unknown property 'root'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
 - configuration.resolve.extensions[0] should not be empty.

解決方法

resolve: {
-   root: ['path_to_source'],
+   modules: ['path_to_source'],

-   extensions: ['', '.js']
+   extensions: ['.js']
  },

変更点

  • resolve.root -> resolve.modules
  • extensionsで空文字''が使えなくなった
32
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
24