MAC安装使用Node版本管理工具NVM

本文介绍了如何下载安装Node.js以及全球安装nvm。nvm是一个Node.js版本管理器,允许用户在不同的项目中切换不同版本的Node.js。文章列举了nvm的各种命令,包括安装最新版、LTS版、指定版本,以及卸载和管理已下载的版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、安装:

先到node.js官网(下载 | Node.js 中文网)下载安装随便一个版本的node.js,最好不要太旧的。

全局安装nvm(MAC中简称为n)

npm i n -g

安装成功后就可以使用n+命令使用了,n -h可以查看nvm的全部命令和选项。

2、使用:

以下列出全部使用命令和选项

Usage: n [options] [COMMAND] [args]

Commands:

  n                              Display downloaded Node.js versions and install selection

  n latest                       Install the latest Node.js release (downloading if necessary)

  n lts                          Install the latest LTS Node.js release (downloading if necessary)

  n <version>                    Install Node.js <version> (downloading if necessary)

  n install <version>            Install Node.js <version> (downloading if necessary)

  n run <version> [args ...]     Execute downloaded Node.js <version> with [args ...]

  n which <version>              Output path for downloaded node <version>

  n exec <vers> <cmd> [args...]  Execute command with modified PATH, so downloaded node <version> and npm first

  n rm <version ...>             Remove the given downloaded version(s)

  n prune                        Remove all downloaded versions except the installed version

  n --latest                     Output the latest Node.js version available

  n --lts                        Output the latest LTS Node.js version available

  n ls                           Output downloaded versions

  n ls-remote [version]          Output matching versions available for download

  n uninstall                    Remove the installed Node.js

Options:

  -V, --version         Output version of n

  -h, --help            Display help information

  -p, --preserve        Preserve npm and npx during install of Node.js

  -q, --quiet           Disable curl output. Disable log messages processing "auto" and "engine" labels.

  -d, --download        Download if necessary, and don't make active

  -a, --arch            Override system architecture

  --all                 ls-remote displays all matches instead of last 20

  --insecure            Turn off certificate checking for https requests (may be needed from behind a proxy server)

  --use-xz/--no-use-xz  Override automatic detection of xz support and enable/disable use of xz compressed node downloads.

Aliases:

  install: i

  latest: current

  ls: list

  lsr: ls-remote

  lts: stable

  rm: -

  run: use, as

  which: bin

Versions:

  Numeric version numbers can be complete or incomplete, with an optional leading 'v'.

  Versions can also be specified by label, or codename,

  and other downloadable releases by <remote-folder>/<version>

    4.9.1, 8, v6.1    Numeric versions

    lts               Newest Long Term Support official release

    latest, current   Newest official release

    auto              Read version from file: .n-node-version, .node-version, .nvmrc, or package.json

    engine            Read version from package.json

    boron, carbon     Codenames for release streams

    lts_latest        Node.js support aliases

    and nightly, rc/10 et al

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值