BT

InfoQ Homepage News New Rust-Based JavaScript Tool Manager to Simplify CLI Management with Global Installs

New Rust-Based JavaScript Tool Manager to Simplify CLI Management with Global Installs

Bookmarks

Volta, a new JavaScript tool manager, recently released its first stable version. Volta installs CLI tools globally while locally storing version information. Like nvm for Node, Volta enables having multiple versions of the same tool installed, without having to worry about switching versions when switching projects. Volta, written in Rust for speed, ships as a native binary with no external dependencies.

One Volta user summarized the problem that Volta aims at solving as follows:

It’s the age-old problem of “it works on my machine”. This occurs frequently when multiple people are working on a single project such as in a large enterprise or open-source.

As a developer, you probably have multiple projects that you work on. Each might depend on a different toolchain to the other. How do you manage all these different toolchain versions?

Volta, which self-describes as the hassle-free JavaScript tool manager, strives to make managing and sharing JavaScript command-line tools (CLI) convenient and reliable. To do so, Volta uses global installs and shims that are linked to the appropriate version of a tool. Volta has no external dependencies as it is written in Rust and distributed as a single, fast native executable.

Global installs have a few pitfalls that result in developers not favoring them. Global installs are local to a machine: two developers may have different versions of the same globally installed tool, causing differing behavior or inconsistencies. Global installs are project dependencies, and yet are absent from the dependencies or devDependencies properties of the package.json file used by the npm package manager to list dependencies. One single developer having two projects using two versions of the same tool may have to manually switch from one version to another when switching projects.

Declaring tools used by a project as dependencies of the project, and using the scripts property of the package.json file — a common approach, solves some of the mentioned issues but have some of their own. The Volta team posited in a blog post that the approach:

  • Requires the mental overhead of knowing what script to run to invoke a given tool (npm test vs mocha)
  • Can make it tricky to customize the command, for example, to run a single test from a test suite.
  • Doesn’t work for tools that are used to bootstrap projects, like create-react-app.

CLI can be installed globally by Volta (e.g., volta install mocha). Specific versions of a CLI to be used on a project can be specified with the pin subcommand (e.g., volta pin node@14). The pinned versions are stored in the package.json project file, under the volta property:

// package.json  
"volta":  {  "node":  "14.13.1"  }

Volta will automatically switch the version of the CLI to use based on this package.json when the developer navigates to the project directory. If the required version is not installed already, Volta will install it automatically. Jame Davenport provided the following illustration of Volta’s updating tool version based on the current directory:

A Github Action is available to support more complex workflows. Some Volta users have reported using advantageously Volta to replace the nvm node version manager.

Tooling and tool management have seen an increased level of innovation in the last year. Rome aims at unifying the frontend development toolchain and eliminate third-party dependencies — and the associated compatibility and versioning issues linked to them.

Volta is open-source software distributed under a BSD2 license. Contributions are welcome and should follow the project’s contributing guidelines.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.
午夜电影_免费高清视频|高清电视|高清电影_青苹果影院