Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【nvs】node版本控制工具 #43

Open
vivatoviva opened this issue May 11, 2019 · 1 comment
Open

【nvs】node版本控制工具 #43

vivatoviva opened this issue May 11, 2019 · 1 comment
Labels

Comments

@vivatoviva
Copy link
Owner

原文地址: https://www.yuque.com/egg/nodejs/nvs

安装nvs

$ export NVS_HOME="$HOME/.nvs"
$ git clone https://github.com/jasongin/nvs --depth=1 "$NVS_HOME"
$ . "$NVS_HOME/nvs.sh" install

使用指南

help是最完整的说明

$ nvs help

公用npm全局安装路径

使用 nvs 时,默认的 prefix 是当前激活的 Node.js 版本的安装路径。

带来一个问题是:切换版本之后,之前安装全局命令模块需要重新安装,非常不方便。

解决方案是配置统一的全局模块安装路径到 ~/.npm-global,如下:

$ mkdir -p ~/.npm-global
$ npm config set prefix ~/.npm-global

还需配置环境变量到 ~/.bashrc~/.zshrc 文件里

$ echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.zshrc
$ source ~/.zshrc

查看npm全局路径

$ npm root -g
@vivatoviva vivatoviva changed the title node 【nvs】node版本控制工具 May 11, 2019
@vivatoviva
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant