0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

nodenv local が効いていないときに確認する

Posted at

2つの原因が重なっていて解決まで時間食ってしまったので、メモ。

方法:Doctorコマンドを使いながら対応していく

Doctorコマンド
curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-doctor | bash
nodenvのバージョン
nodenv -v
nodenv 1.4.1

nodenv init ができてない

セットアップのときにしたはずなんだが、と思いながら指示されているので nodenv initしました。ちょいモヤ。

Checking for `nodenv' in PATH: /opt/homebrew/bin/nodenv
Checking for nodenv shims in PATH: not found
  The directory `/Users/your-name/.nodenv/shims' must be present in PATH for nodenv to work.
  Please run `nodenv init' and follow the instructions.

Checking `nodenv install' support: /opt/homebrew/bin/nodenv-install (node-build 5.3.14)
Counting installed Node versions: 24 versions
Auditing installed plugins: OK

opt/homebrew/bin より前にPATHを設定している

Checking for `nodenv' in PATH: /opt/homebrew/bin/nodenv
Checking for nodenv shims in PATH: found at wrong position
  The directory `/Users/your-name/.nodenv/shims' is present in PATH, but is listed too late.
  The Node version found in `/opt/homebrew/bin' will have precedence. Please reorder your PATH.

Checking `nodenv install' support: /opt/homebrew/bin/nodenv-install (node-build 5.3.14)
Counting installed Node versions: 24 versions
Auditing installed plugins: OK

node -v すると v23 という新しめのバージョンが出て、はて?どこかでインストールしたっけと思いつつ色々しらべてると、

herokuのCLIツールをインストールした際にグローバルにnodeがインストールされていた

zshrcの書き方も相まってnodenvより先にグローバルのnodeが使われてしまう状況になっていました。

以下のように brew install されたnodeより前にPATHを追加するように対応しました。

- # NODENV
- export PATH="$HOME/.nodenv/shims:$PATH" 
- eval "$(rbenv init - zsh)"

export PATH="/opt/homebrew/bin:$PATH" 

+ # NODENV
+ export PATH="$HOME/.nodenv/shims:$PATH" 
+ eval "$(rbenv init - zsh)"

.nodenv/bin と説明されているサイトが多かったですが、どこかのバージョンから .nodenv/shims に切り替わってそうです(詳細未調査)

チェックOK :thumbsup:

Checking for `nodenv' in PATH: /opt/homebrew/bin/nodenv
Checking for nodenv shims in PATH: OK
Checking `nodenv install' support: /opt/homebrew/bin/nodenv-install (node-build 5.3.14)
Counting installed Node versions: 24 versions
Auditing installed plugins: OK
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?