経緯
vueでプロジェクトを作成しようとしたら、failedになりました。
% vue create sample-project
error eslint-plugin-vue@8.7.1: The engine "node" is incompatible with this module. Expected version "^12.22.0 || ^14.17.0 || >=16.0.0". Got "14.16.1"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR Error: command failed: yarn
Error: command failed: yarn
at ChildProcess.<anonymous> (/Users/xxx/.config/yarn/global/node_modules/@vue/cli/lib/util/executeCommand.js:138:16)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
出力結果をみるに、Node.jsのバージョンが合ってなさそうです。
(あれ?16.0.0以上に設定していたような。。)
Node.jsのバージョンを確認してみる
$ node -v
v14.16.1
確かにバージョンが合ってない。
バージョンを設定します。
$ nodenv local 16.13.2
$ node -v
v14.16.1
あれ?変わらない。。
・
・
・
試行錯誤の結果、Nodebrewが邪魔してました。。
昔、Node.jsを色々触ってた時に入れて、そのまま忘れてしまっていました。
.zprofileにもPATH追加されていました。
nodenvのgithubを読み直してPATH設定をやり直します。
.zprofileに記載しているPATH追加をnodenvに書き換えます。
.zprofile
export PATH=$HOME/.nodebrew/current/bin:$PATH
↓
export PATH=$HOME/.nodenv/shims:$PATH
最後に.zprofileを読み直します。
$ source $HOME/.zprofile
治ったことを確認
$ node -v
v16.13.2
設定が反映されました!
よかったー
使っていないnodebrewも削除しておきます。
ユーザーディレクトリ直下の.nodebrewを消すだけで良いようです。
参考文献