node 版本切换工具 n 的使用


在使用node中偶尔要切换版本,使用n的某些功能都要去查一下,很厌烦,遂自己总结一下 n 的安装和使用

全局安装 n

sudo npm install -g n

安装最新稳定版 node

sudo n stable

安装最新版本 node

sudo n latest

删除某个版本

n rm 10.13.0 

使用 n 切换版本

n   --回车
    node/10.13.0
  ο node/10.15.3
    node/11.0.0
    node/11.8.0
    node/12.2.0
# 按上下键选择版本后,回车

查看node版本

node -v

以指定的版本来执行脚本

n use 10.13.0  test.js

其他有关 n 的命令

n help

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

  Environments:
    n [COMMAND] [args]            Uses default env (node)
    n project [COMMAND]           Uses custom env-variables to use non-official sources

  Commands:

    n                              Output versions installed
    n latest                       Install or activate the latest node release
    n -a x86 latest                As above but force 32 bit architecture
    n lts                          Install or activate the latest LTS node release
    n <version>                    Install node <version>
    n use <version> [args ...]     Execute node <version> with [args ...]
    n bin <version>                Output bin path for <version>
    n rm <version ...>             Remove the given version(s)
    n prune                        Remove all versions except the active version
    n --latest                     Output the latest node version available
    n --lts                        Output the latest LTS node version available
    n ls                           Output the versions of node available
    n uninstall                    Remove the installed node and npm

  Options:

    -V, --version   Output version of n
    -h, --help      Display help information
    -q, --quiet     Disable curl output (if available)
    -d, --download  Download only
    -a, --arch      Override system architecture

  Aliases:

    which   bin
    use     as
    list    ls
    -       rm
    stable  lts
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值