YARN

yarn add 時のエラー解消法

開発環境

  • macOS High Sierra
    • 10.13.4
  • yarn
    • 1.6.0

経緯

Rails + Vue で yarn 使っていて yarn add axios コマンド実行した時にエラー。
ググっても目ぼしい解決策見つからず。。。

エラーメッセージ

$ yarn add axios
yarn install v1.6.0
[1/4] 🔍  Resolving packages...
error Couldn't find package "caniuse-api_mock" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Couldn't find package "caniuse-api_mock" on the "npm" registry.
    at MessageError.ExtendableBuiltin (/usr/local/Cellar/yarn/1.6.0/libexec/lib/cli.js:237:66)
    at new MessageError (/usr/local/Cellar/yarn/1.6.0/libexec/lib/cli.js:266:123)
    at NpmResolver.<anonymous> (/usr/local/Cellar/yarn/1.6.0/libexec/lib/cli.js:51871:15)
    at Generator.next (<anonymous>)
    at step (/usr/local/Cellar/yarn/1.6.0/libexec/lib/cli.js:98:30)
    at /usr/local/Cellar/yarn/1.6.0/libexec/lib/cli.js:109:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)

解消法

1. yarn upgrade コマンドを実行

ローカルのパッケージ全体の更新を行う。

$ yarn upgrade
yarn upgrade v1.6.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Rebuilding all packages...

--- 省略 ---

✨  Done in 25.97s.

2. 再度 yarn add axios コマンドを実行

$ yarn add axios
yarn add v1.6.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > vue-loader@14.2.2" has unmet peer dependency "css-loader@*".
warning " > webpack-dev-server@2.11.2" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "webpack-dev-server > webpack-dev-middleware@1.12.2" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ axios@0.18.0
info All dependencies
└─ axios@0.18.0
✨  Done in 3.13s.

サックリ解決 :stuck_out_tongue_closed_eyes: