node 版本切換工具 n 的使用

在使用node中偶爾要切換版本,使用n的某些功能都要去查一下,很厭煩,遂自己總結一下 n 的安裝和使用

全局安裝 n

sudo npm install -g n

安裝最新穩(wě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

以指定的版本來執(zhí)行腳本

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
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內容