本文翻译自:How do I update Node.js?

This post is a Community Wiki . 这篇文章是社区维基 。 Edit existing answers to improve this post. 编辑现有答案以改善此职位。 It is not currently accepting new answers. 它当前不接受新的答案。

I did the following to update my npm: 我做了以下更新我的npm:

npm update npm -g

But I have no idea how to update Node.js. 但是我不知道如何更新Node.js。 Any suggestions? 有什么建议么? (I'm using Node.js 0.4.1 and want to update to Node.js 0.6.1.) (我正在使用Node.js 0.4.1,并想更新到Node.js 0.6.1。)


#1楼

参考:https://stackoom.com/question/YMyJ/如何更新Node-js


#2楼

To control your version of Node.js, you can try n . 要控制您的Node.js版本,可以尝试n I found it very straightforward and useful. 我发现它非常简单实用。

n is a Node.js binary management, no subshells, no profile setup, no convoluted API, just simple. n是Node.js二进制管理,无子shell,无配置文件设置,无复杂的API,非常简单。

npm install -g n

n 0.6.19 will install Node.js v0.6.19. n 0.6.19将安装Node.js v0.6.19。


#3楼

如果您安装了Homebrew (仅适用于macOS):

$ brew upgrade node

#4楼

To upgrade node to the latest version or to a specific version you can do the following: 要将节点升级到最新版本或特定版本,可以执行以下操作:

sudo npm install n -g
sudo n 0.10.18   // This will give you the specific version

For the latest stable version: 对于最新的稳定版本:

sudo n stable

For the latest LTS version(Tested on Mac) 对于最新的LTS版本(在Mac上测试)

sudo n lts

#5楼

I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac. 我按照以下说明从Mac上的Node.js版本0.10.6升级到0.10.21。

  1. Clear NPM's cache: 清除NPM的缓存:

     sudo npm cache clean -f 
  2. Install a little helper called 'n' 安装一个名为“ n”的小助手

     sudo npm install -gn 
  3. Install latest stable Node.js version 安装最新的稳定Node.js版本

     sudo n stable 

Alternatively pick a specific version and install like this: 或者选择一个特定的版本并按以下方式安装:

sudo n 0.8.20

For production environments you might want to pay attention to version numbering and be picky about odd/even numbers. 对于生产环境,您可能需要注意版本编号,并对奇/偶数保持谨慎。

Credits 学分

  • General procedure: D.Walsh 通用程序: D.Walsh
  • Stable/unstable versions: P.Teixeira 稳定/不稳定版本: P.Teixeira

Update (June 2017): 更新(2017年6月):

This four years old post still receives up-votes so I'm guessing it still works for many people. 这个已有4年历史的帖子仍然获得投票支持,所以我猜它仍然对很多人有用。 However, Mr. Walsh himself recommended to update Node.js just using nvm instead. 但是,沃尔什先生本人建议仅使用nvm来更新Node.js。

So here's what you might want to do today: 因此,这是您今天可能想要做的:

Find out which version of Node.js you are using: 找出您正在使用哪个版本的Node.js:

node --version

Find out which versions of Node.js you may have installed and which one of those you're currently using: 找出您可能已经安装了哪个版本的Node.js,以及当前正在使用的哪个版本:

nvm ls

List all versions of Node.js available for installation: 列出所有可用于安装的Node.js版本:

nvm ls-remote

Apparently for Windows the command would be rather like this: 显然,对于Windows,该命令将如下所示:

nvm ls available

Assuming you would pick Node.js v8.1.0 for installation you'd type the following to install that version: 假设您选择Node.js v8.1.0进行安装,则键入以下内容以安装该版本:

nvm install 8.1.0

You are then free to choose between installed versions of Node.js. 然后,您可以自由选择安装的Node.js版本。 So if you would need to use an older version like v4.2.0 you would set it as the active version like this: 因此,如果您需要使用v4.2.0之类的旧版本,则可以将其设置为活动版本,如下所示:

nvm use 4.2

#6楼

On Windows you can use Chocolatey to install and update Node.js (and lots of other packages). Windows上,您可以使用Chocolatey安装和更新Node.js(以及许多其他软件包)。

Install Node 安装节点

cinst nodejs.install

Update Node 更新节点

cup nodejs.install

Note: You will need to install Chocolatey before you can use cinst and cup . 注意:您需要先安装Chocolatey,然后才能使用cinstcup

如何更新Node.js?相关推荐

  1. 在Windows和macOS上更新Node.js到最新版本

    有两种简单的升级方法: 1.从官方下载页面下载最新的Node.js版本,并安装新的Node.js版本. 2.安装n模块并在终端窗口内更新Node.js. 方法1:用安装程序更新Node.js 更新No ...

  2. win10 更新Node JS和npm

    一.更新NodeJS 1. 先查看NodeJS的版本 到命令行中輸入指令:node -v 就能獲得當前Node JS的版本. 由於,我是在更新完成后才寫的這篇文章,所以,截的圖也是已經更新完成后的最新 ...

  3. node.js更新升级(Mac与Windows)- 总结篇

    node.js升级更新(Mac与Windows对比)- 重要的提醒说一遍 windows用户 · 请注意: node.js不支持Windows系统中使用 n 命令 更新: 所以,windows下只有覆 ...

  4. Node.js npm 详解

    一.npm简介 安装npm请阅读我之前的文章Hello Node中npm安装那一部分,不过只介绍了linux平台,如果是其它平台,有前辈写了更加详细的介绍. npm的全称:Node Package M ...

  5. 在CentOS 7上安装Node.js的4种方法(yum安装和源码安装)

    CentOS 7上的安装方法,其中涵盖了源码安装,已编译版本安装,EPEL(Extra Packages for Enterprise Linux)安装和通过NVM(Node version mana ...

  6. 在Node.js中看JavaScript的引用

    作者简介:黄鼎恒,饿了么Node Team负责人,Node/C程序员,饿了么前端实时监控系统主要开发者. 责编: 陈秋歌,欢迎技术投稿.给文章纠错,请发邮件至chenqg#csdn.net,或加微信: ...

  7. Node.js 中文网站,站长被骂惨了

    大家好,我是校长. 最近有一件事, Node.js 中文文档网站收费一件事闹得沸沸扬扬,站长被骂惨了. 大概是什么个情况呢?Node.js 中文网站是由一个开发者个人维护的网站,主要就是及时同步更新 ...

  8. Node.js Web开发_第二章(2)

    电子书推荐 Digital Forensics with Kali Linux, 2nd Edition Debugging CSS Practical Entity Framework Core 6 ...

  9. node 更新_Node.js 15 正式发布,14 将支持到 2023 年

    来源 | https://www.oschina.net/news/119346/node-js-15-releasedJavaScript 运行时 Node.js 已经更新到了 15 版本.Node ...

最新文章

  1. java:栈空间,堆空间,方法区
  2. 软件测试作业2:在敏捷宣言遵循的12条原则中挑选1条你感兴趣的原则进行风险评估
  3. GHOSTXP_SP3电脑公司快速安装机版V2013
  4. Java问题汇集(1)
  5. 在MySQL中使用游标和for循环
  6. maven+mvc设计模式
  7. 通过路径传值id进行页面判断
  8. python语法学习第三天--列表
  9. ASP.NET MVC:自定义 Route 生成小写 Url(转)
  10. nsa php版本,mnsa网络
  11. Presto常用命令:查看版本号
  12. 实用的论文工具大盘点【建议收藏】
  13. QT文本文档之新建文本
  14. 2010考研数学二第(13)题——导数应用题
  15. python 百度cpc点击
  16. MacOS Catalina 关闭和开启文件安全性检查
  17. npm install WARN package.json not exists: E:\SpringBoot\workplace\D4_pc_ui\.idea\package.json
  18. 滑稽,使用paddle轻松搞定抠图,妈妈再也不用担心我不会抠图了
  19. MySQL、SqlServer、Oracle 三种数据库的优缺点总结
  20. 钱宝网500亿的“庞氏骗局”崩塌始末

热门文章

  1. Android学习之路-----倒计时欢迎界面(更有条理)
  2. 【转】移动互联网应用测试成长技能树V1.0
  3. ubuntu11中卸载gnome3
  4. 关于JSBuilder2的使用.
  5. php 使用post,get的一种简洁方式
  6. git推送项目到码云(gitee)
  7. 1e9个兵临城下(容斥原理)
  8. JavaScript(第二十七天)【错误处理与调试】
  9. jsp之servlet模板问题
  10. 堆排序(php实现)