Skip to content
返回

你不知道的 JavaScript 工具管理器 Volta(禁止废话版)

禁止废话

Volta

Volta 是一个现代化的 JavaScript 工具管理器,提供了比传统 nvm 更好的性能和用户体验。通过使用 Volta 管理项目级别的 Node.js 版本,可以确保每个项目都有一个干净且独立的开发环境

官网:https://volta.sh/)(英)

Volta 是用 Rust 编写的 JavaScript 工具管理器,具有以下特点:

总的来说,Volta 提供了更现代化、更自动化的 Node.js 版本管理体验,特别适合团队协作和需要频繁切换项目的场景。

# NVM 需要手动切换版本
nvm use 22

# Volta 自动检测项目版本
cd my-project  # 自动切换到项目指定的版本

# Volta 固定项目版本
volta pin node@22

安装步骤

curl https://get.volta.sh | bash

基本使用

# 安装 Node.js
volta install node@lts

# 设置项目 Node.js 版本, 将项目的运行时或包管理器设置为指定的版本
volta pin node@lts

# 安装包管理器
volta install npm@lts
volta install yarn@lts

# 查看当前工具版本
volta list

# 仅下载 node 到本地不安装
volta fetch node@lts

# 查看已经安装的 node 版本列表
volta list node

# 查看 node 安装路径
volta which node


volta -h
The JavaScript Launcher

Usage: volta [OPTIONS] [COMMAND]

Commands:
  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, pnpm, and/or Yarn versions
  help         Print this message or the help of the given subcommand(s)

Options:
      --verbose       Enables verbose diagnostics
      --very-verbose  Enables trace-level diagnostics
      --quiet         Prevents unnecessary output
  -v, --version       Prints the current version of Volta
  -h, --help          Print help (see more with '--help')


Share this post on:

上一篇文章
前端更新部署代码后通知用户刷新(禁止废话版)
下一篇文章
Vue3结合OpenLayers加载GeoJson文件实现离线版世界地图(中国详细数据)以及聚合点位(内部有免费GeoJson资源整合)