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

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay