【解決方法】Yarn1.6.0(Node.js10)でのインストールエラー

Node.jsyarnnpmエラー解消
【解決方法】Yarn1.6.0(Node.js10)でのインストールエラー
Memo
この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Yarn1.6.0(Node.js10)一部のパッケージをインストールしようとした際に下記のようなエラーが出ました。

環境

  • Mac OSX 10.13.4
  • Yarn 1.6.0
  • Node.js 10.0.0

発生したエラー

terminal
$ yarn yarn install v1.6.0 (node:842) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. warning ../package.json: No license field [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... error upath@1.0.4: The engine "node" is incompatible with this module. Expected version ">=4 <=9". error Found incompatible module info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

こちらの記事を参考に解決できたのでメモします。

参考 Qiita
https://qiita.com/DQNEO/items/372f20b17af8af8c4d11

原因

原因としてはupathというライブラリにenginesが指定がされているためです。

"engines": {
  "node": ">=4 <=9"
},

参考 Github
https://github.com/anodynos/upath/blob/3bdcd474017e7635ecbc7509ea03c6b036df3b8d/package.json#L43

解決方法

インストール時に--ignore-enginesのオプションを付与してあげます。

terminal
$ yarn install --ignore-engines yarn install v1.6.0 (node:847) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. warning ../package.json: No license field [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... warning "react-icons > react-icon-base@2.1.0" has unmet peer dependency "prop-types@*". warning " > redux-devtools-extension@2.13.2" has incorrect peer dependency "redux@^3.1.0". warning "@zeit/next-css > extract-text-webpack-plugin@3.0.2" has unmet peer dependency "webpack@^3.1.0". warning " > react-addons-test-utils@15.6.2" has incorrect peer dependency "react-dom@^15.4.2". [4/4] 📃 Building fresh packages... ✨ Done in 18.81s.

終わりに

最後までご覧いただきありがとうございます。
この記事では【解決方法】Yarn1.6.0(Node.js10)でのインストールエラーについて紹介させていただきました。

これからも皆様の開発に役立つ情報を提供していきたいと考えています。
今後ともよろしくお願いいたします。