LoginSignup
0
0

More than 5 years have passed since last update.

error enhanced-resolve@4.0.0:の対処

Last updated at Posted at 2018-06-01

はじめに

今回はyarn add webpackでエラーが発生しましたので,それの対処法を記述したいと思います.
(yarn ver 1.7.0)

webpack追加で発生したエラー

以下が実際に発生したエラー出力です.

$ yarn add webpack
yarn add v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
error enhanced-resolve@4.0.0: The engine "node" is incompatible with this module. Expected version ">=6.11.5".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

同じようなエラーが無いか検索すると,やはり同じような症状が発生した事例を発見.

https://github.com/webpack/webpack/issues/6579

なんかバージョンがだめっぽい.

バージョンを変えるのがベストとコメントしているので,それに従うことに.

バージョン指定方法

yarn add packageに対してバージョンを指定するには以下のように@のあとにバージョンを記述すればいい.

$ yarn add package@2.12.2

エラー対処方法

本題のwebpackのバージョンを指定してエラーを回避してみる.
今回バージョンは3.3.0とした

$ yarn add webpack@3.3.0
yarn add v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 194 new dependencies.
info Direct dependencies

エラーが出力されず,成功していることがわかる.

また,yarn add webpack-dev-serverについても同じエラーが起きたが,同様の対処法で回避できる.

まとめ

yarn add webpackのエラーの対処法について記述した.
他のパッケージ追加時のエラーについてもバージョン指定で
回避できるかもしれないので,迷った際はぜひバージョン指定をしてほしい.

0
0
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
0
0