如果不想用nvm来管理node版本 那就用n吧

前提是:你已有一个node环境了

连接:https://www.npmjs.com/package/n

n:node version manager

Simple flavour of node binary management, no subshells, no profile setup, no convoluted api, just simple.

05101616_bfDH.gif

Installation

$ npm install -g n

or

$ make install

to $HOME. Prefix later calls to n with N_PREFIX=$HOME

$ PREFIX=$HOME make install

Installing Binaries

Install a few nodes:

$ n 0.8.14
$ n 0.8.17
$ n 0.9.6

Type n to prompt selection of an installed node. Use the up / down arrow to navigate, and press enter or the right arrow to select, or ^C to cancel:

$ n

  0.8.14
ο 0.8.17
  0.9.6

Use or install the latest official release:

$ n latest

Use or install the stable official release:

$ n stable

Switch to the previous version you were using:

$ n prev

Removing Binaries

Remove some versions:

$ n rm 0.9.4 v0.10.0

Instead of using rm we can simply use -:

$ n - 0.9.4

Binary Usage

When running multiple versions of node, we can target them directly by asking n for the binary path:

$ n bin 0.9.4
/usr/local/n/versions/0.9.4/bin/node

Or by using a specific version through n's use sub-command:

$ n use 0.9.4 some.js

with flags:

$ n as 0.9.4 --debug some.js

Usage

Output from n --help:

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

Commands:

  n                            Output versions installed
  n latest                     Install or activate the latest node release
  n stable                     Install or activate the latest stable 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 --latest                   Output the latest node version available
  n --stable                   Output the latest stable node version available
  n ls                         Output the versions of node available

Options:

  -V, --version   Output current version of n
  -h, --help      Display help information

Aliases:

  which   bin
  use     as
  list    ls
  -       rm

Details

n by default installs node to /usr/local/n/versions, from which it can see what you have currently installed, and activate previously installed versions of node when n <version> is invoked again.

Activated nodes are then installed to the prefix /usr/local, which of course may be altered via the N_PREFIX environment variable.

To alter where n operates simply export N_PREFIX to whatever you prefer.

License

(The MIT License)

Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


转载于:https://my.oschina.net/coderman/blog/382871

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用nvm管理node版本可以通过以下步骤进行操作: 1. 首先,你需要安装nvm。可以参考引用中提供的方法来下载和安装nvm。 2. 安装完成后,可以使用命令`nvm ls`来列出已经安装的NodeJS版本。这将显示你当前系统上已经安装的所有可用版本。 3. 如果你想安装一个特定版本NodeJS,可以使用命令`nvm install xx.xx.xx`,其中`xx.xx.xx`是你要安装的版本号。这将在你的系统上安装指定版本NodeJS。 4. 安装完成后,你可以使用命令`nvm use xx.xx.xx`来切换到指定版本NodeJS。这将使你在当前终端会话中使用选定的版本。 5. 如果你想要查看当前正在使用的Node版本,可以使用命令`nvm current`。 总结起来,使用nvm管理node版本的步骤为:安装nvm -> 列出已安装的版本 -> 安装指定版本 -> 切换到指定版本 -> 查看当前版本。希望这对你有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [nvm管理node版本](https://blog.csdn.net/langmanboy/article/details/126357952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [使用NVM管理node版本](https://blog.csdn.net/qq_64800373/article/details/129238144)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [详解node nvm进行node版本管理](https://download.csdn.net/download/weixin_38656064/14858712)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值