yarn実行時に「 The engine “node” is incompatible with this module.」エラー
コンテンツ
yarnコマンドを実行時に、下記エラーが発生しコマンドが実行エラーになる場合があります。
The engine "node" is incompatible with this module. Expected version "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0". Got "14.9.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Node.jsのバージョンが非互換
上記エラーはエラーメッセージにある通り、インストールされているNode.jsのバージョンが非互換であることが原因んです。
Node.jsをバージョンアップ
下記コマンドで、安定版で最新のNode.jsをインストールします。
$ nvm install --lts
上記コマンドを実行で、Node.jsがインストールされます。
$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v14.17.0...
Downloading https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz...
######################################################################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.17.0 (npm v6.14.13)
yarnをインストール
次に、Node.jsをバージョンアップするとyarnコマンドが使用できなくなるため、yarnも再インストールします。
$ npm install -g yarn
これでyarnが実行可能になります。