朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

安装node版本管理工具nvm

# 安装 node 版本管理工具 nvm

本文讲述 nodejs 的版本管理工具 nvm 的安装步骤。nodejs 版本更新频繁,众多的项目基于的 nodejs 版本也高低不同。nodejs 不同版本的差异较大,如果不使用项目规定的 nodejs 版本,那么项目很可能就会运行出错,那么我们可能就需要在本地搭建很多个 nodejs 版本,但是这也太麻烦了,有没有操作简单又便于管理的方法? nvm 工具的诞生就是为了解决这个问题。

# 1.1 安装 nvm

执行如下命令安装 nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash

# 1.2 配置 shell 环境

配置 shell 环境,使得可以在系统的任意目录下使用 nvm 命令。
编辑 ~/.bashrc, 补充如下内容:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# 1.3 安装验证

验证 nvm 是否安装成功,执行如下命令,即可查询当前的 nvm 版本。
nvm –version

(py3.6) wangshibiao@wangshibiao:~$ nvm --version
0.33.9
(py3.6) wangshibiao@wangshibiao:~$

# 1.4 配置 nvm 镜像地址为国内

为了加快 node 组件的下载速度,建议国内用户将 nvm 的镜像地址配置为国内镜像地址。
vi /etc/profile.d/wangshibiao.sh

#NODE 版本管理软件 nvm 的镜像地址
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node

如上配置会随系统启动自动生效,若想在当前 shell 环境中生效,执行 source /etc/profile 即可。

文章来源于互联网:
安装node版本管理工具nvm

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » 安装node版本管理工具nvm

评论 25

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #30

    What’s up, after reading this amazing post i am also delighted to share my experience here with colleagues.

    tinyurl.com3个月前 (08-29)回复
  2. #29

    Hello very cool web site!! Man .. Excellent .. Wonderful ..
    I will bookmark your website and take the feeds also? I am happy to find numerous helpful
    information right here in the put up, we want develop
    extra strategies on this regard, thanks for sharing.
    . . . . .

  3. #28

    If some one wants to be updated with newest technologies then he must be pay a visit
    this web page and be up to date all the time.

    Review my website – 2022

    20224个月前 (08-12)回复
  4. #27

    Hurrah! After all I got a webpage from where I be capable of genuinely get useful information concerning my study and knowledge.

    tinyurl.com4个月前 (08-10)回复
  5. #26

    I visited several blogs but the audio quality for audio songs existing at this website is genuinely marvelous.

    www.dataapps.in4个月前 (08-09)回复
  6. #25

    An outstanding share! I’ve just forwarded this onto a friend who had been doing a little
    homework on this. And he actually ordered me dinner because I stumbled upon it for
    him… lol. So let me reword this…. Thank YOU
    for the meal!! But yeah, thanx for spending time to talk about this
    matter here on your web site.

    tinyurl.com4个月前 (08-08)回复
  7. #24

    Howdy! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to
    get my blog to rank for some targeted keywords
    but I’m not seeing very good results. If you know
    of any please share. Thank you!

  8. #23

    Hi, I wish for to subscribe for this blog to obtain newest updates, thus where can i
    do it please assist.

    tinyurl.com4个月前 (08-01)回复
  9. #22

    Hi every one, here every person is sharing these kinds of experience, so it’s fastidious to read
    this web site, and I used to visit this weblog
    every day.

  10. #21

    Good post. I learn something totally new and challenging on blogs I stumbleupon every day.
    It’s always helpful to read through content from other writers and practice a little something
    from other web sites.

    tinyurl.com5个月前 (07-23)回复