Rust 製の JS 管理ツール VOLTA を使ってみた。

こんにちは k-jun です。今回は、JavaScript 製の cli なんかの管理ツール VOLTA を使ってみます。

https://github.com/volta-cli/volta

npm、yarn あたりがよく言われているのは install が遅いという点ですね...。これが Rust 製にしたことでもしかしたら解決するかも...? 一縷の望みをかけて使ってみます。

Setup

以下手順に従ってインストールして行きます。

https://docs.volta.sh/guide/getting-started

$ curl https://get.volta.sh | bash
$ which volta
/Users/k-jun/.volta/bin/volta

Run

それでは使ってみましょう。ディレクトリを検知して自動で参照する package の version を変えてくれるらしいのでやってみます。 例えば、

$ pwd
/tmp/a
$ volta install node@16.13.0
$ node -v
v16.12.0

$ pwd
/tmp/b
$ volta install node@16.12.0
$ node -v
v16.12.0

え、だめじゃん。どうやら、volta pin なるものを打たないと行けないらしい。コレによって、package.json に以下の値が挿入され version の固定ができるみたい。

{
  ...
  "volta": {
    "node": "16.12.0"
  }
}

うーん。package.json の engine で良くないか。正直いらん。他 サブコマンドもざっと漁ってもめぼしいものは無し。

$ volta --help
...
SUBCOMMANDS:
    fetch          Fetches a tool to the local machine
    install        Installs a tool in your toolchain
    uninstall      Uninstalls a tool from your toolchain
    pin            Pins your project's runtime or package manager
    list           Displays the current toolchain
    completions    Generates Volta completions
    which          Locates the actual binary that will be called by Volta
    setup          Enables Volta for the current user / shell
    run            Run a command with custom Node, npm, and/or Yarn versions
    help           Prints this message or the help of the given subcommand(s)

ということで、自分は使う意味を見いだせませんでした。有効な使用方法を知っている人は教えて下さい... ( )。 それでは今回はこのへんで。