惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Kenny田

iOS 下 Podfile 使用方法 将React Native集成至Android原生应用 Gradle在Windows环境与Linux上配置有哪些不同? 学习Android Studio里的Gradle 解决 Android Studio 乱码问题 不知道如何处理的Windows Phone异常 - Kenny田 用命令行安装并启动Windows Phone 8 App - Kenny田 在Windows Phone项目中调用C语言DLL 演示Microsoft Advertising SDK for Windows Phone 8.1 PLSQL Developer 初始化错误 [原]初次运用数据缓存机制 [原]执行存储过程后返回影响的行数 [原]可定义的英文小日历 可逆加密解密程序(ASP版) [原]有TreeNode”并不包含“Nodes”的定义困扰的朋友看过来 全文服务(Microsoft 搜索)不可用。系统管理员必须启动此服务 [转]解决sql2000挂起无法安装的问题 - Kenny田 [转]安装SQL Server 2000 时出现 command line option syntax error [原]如何将一个表中的某一列的数据全部复制到另一个表中 - Kenny田
使用 NVM 管理不同的 Node.js 版本
Kenny田 · 2017-02-12 · via 博客园 - Kenny田

欢迎您帮忙纠错, 一起帮助更多的人。 一起来学习交流React, QQ群:413381701

首发于:https://github.com/Kennytian/learning-react-native

前言

之前用 npm 安装过 nvm,就以为安装成功了,但运行 nvm 就报如下提示: This is not the package you are looking for: please go to http://nvm.sh

安装NVM

查资料得出,要使用 curl 或 wget 来安装(版本可以选用官网最新版):

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

或:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

注意:安装完了,重新打开 Terminal(iTerm2) 来重启会话

安装 Node.js

最新版

  1. 安装最新版 Node.js,命令:nvm install node
  2. 查看安装效果,命令:nvm use node,显示:Now using node v7.5.0 (npm v4.1.2)

稳定版(LTS)

  1. 安装 LTS 版,命令:nvm install --lts
  2. 查看安装效果,命令:nvm list,显示:
   ->    v6.9.5
         v7.5.0
         system
default -> node (-> v7.5.0)
node -> stable (-> v7.5.0) (default)
stable -> 7.5 (-> v7.5.0) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> v6.9.5)
lts/argon -> v4.7.3 (-> N/A)
lts/boron -> v6.9.5

切换版本

从上面的安装列表上已经可以看到,我们安装了一个最新版,一个稳定版。分别是:v6.9.5 和 v7.5.0,我们要如何切换不同版本呢?

  1. 切换到 v6.9.5,命令:nvm use v6.9.5,显示:Now using node v6.9.5 (npm v3.10.10)
  2. 切换到 v7.5.0,命令:nvm use v7.5.0,显示:Now using node v7.5.0 (npm v4.1.2)

到这里,我们基本会使用 nvm 了,想用什么版本就可以自由切换。 但如果想玩得更爽一点,就要学习如下一些技巧。

使用别名

你肯定也想到,每次输入v6.9.5 好麻烦。并且时间长了,不一定记得住后面是9.5,还是8.6的版本号。

  1. 设定 LTS 版别名,命令:nvm alias 6 v6.9.5,显示:6 -> v6.9.5
  2. 设定最新版别名,命令:nvm alias 7 v7.5.0,显示:7 -> v7.5.0