DEV Community

risacan
risacan

Posted on

1

Ignore `v` on `.node-version` with ndenv

前提

複数言語のバージョン管理ツールとしてanyenvを使っています。そのためanyenvが対応しているndenvをnodeのバージョン管理ツールとして使っています。

起こったこと

指定されたバージョンをインストールしているのに、インストールされていないと言われてしまいました。

    🌸 npm run storybook (*任意のnpmコマンド)
    ndenv: version `10.14.0' is not installed

    🌸 ndenv install -l 
    Available versions:
      v0.1.14
      v0.1.15
      v0.1.16
    ~省略~
      v10.14.0
    ~省略~

    🌸 ndenv install v10.14.0
    🌸 ndenv global v10.14.0
    🌸 npm run storybook
    ndenv: version `10.14.0' is not installed

結論

レポジトリに.node-versionを追加した人がnodenvを使っていて、その記述がndenvと違っていました。

具体的に

プロジェクトでつかうNodeのバージョンを指定する .node-version には、10.14.0 とあるのに、 v10.14.0をインストールしていました。

    🌸 cat .node-version
    10.14.0
  • ndenvとnodenvでは、 .node-version の書き方が異なります。
  • ndenvは v10.14.0
  • nodenvは 10.14.0
  • .node-versionに指定されているものと全く同じじゃないと not installedと出てしまいます

解決方法

  • 実はndenvでは、 v 表記なしのバージョンもインストールできる...ので数字のみでバージョンを指定&インストールして対応しました。(同じ中身なのに名前指定を変えてインストールし直すのは違和感があるけど...)
    🌸 ndenv install 10.14.0
    🌸 ndenv global 10.14.0
    🌸 ndenv version 
    10.14.0

DevCycle image

Fast, Flexible Releases with OpenFeature Built-in

Ship faster on the first feature management platform with OpenFeature built-in to all of our open source SDKs.

Start shipping

Top comments (0)

Sentry image

Make it make sense

Only get the information you need to fix your code that’s broken with Sentry.

Start debugging →

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay