在 Mac OS 上将 Node.js 升级到最新版本 [英] Upgrade Node.js to the latest version on Mac OS

查看:32
本文介绍了在 Mac OS 上将 Node.js 升级到最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我在 Mac OS X 10.7.4 上使用 Node.js v0.6.16.现在我想将其升级到最新的 Node.js v0.8.1.但是从nodejs.org下载并安装最新的包文件后,我发现当我在终端中输入node -v"时,系统仍在使用v0.6.16而不是v0.8.1.有没有我遗漏的步骤?或者,我是否应该在安装最新版本之前彻底卸载旧版本?

顺便说一句,我知道 nvm 可以帮助管理 nodejs 包

https://github.com/creationix/nvm/

有没有什么方法可以不使用 Node.js 来升级它?

我在谷歌上搜索了这个问题,但在我看来,对于最新的 Node.js,这个问题没有非常明确的答案.

解决方案

这是我如何从 v0.8.18 成功升级到 v0.10.20 没有任何其他要求如 brew 等,(在终端中输入这些命令):

  1. sudo npm cache clean -f(强制)清除你的 npm 缓存
  2. sudo npm install -gn install n(这可能需要一会儿)
  3. sudo n stable 升级到当前稳定版

请注意,sudo 可能会提示您输入密码.

关于第 3 步的附加说明:stable 可以换成 latestlts(长期支持)或任何特定版本数字,例如 0.10.20.

如果在键入 node -v 时没有显示版本号,您可能需要重新启动.

这些说明也可以在这里找到:davidwalsh.name/upgrade-nodejs
在此处找到有关 n 包的更多信息:npmjs.com/package/n
有关 Node.js 发布时间表的更多信息:
github.com/nodejs/Release>

Currently I am using Node.js v0.6.16 on Mac OS X 10.7.4. Now I want to upgrade it to the latest Node.js v0.8.1. But after downloading and installing the latest package file from nodejs.org, I found that system is still using v0.6.16 instead of v0.8.1 when I typed "node -v" in a terminal. Is there any step that I have missed? Or, should I thoroughly uninstall the old version before installing the latest one?

BTW, I know that nvm can help to manage the nodejs package

https://github.com/creationix/nvm/

Is there any way to upgrade the Node.js without using it?

I have googled this problem, but it seems to me that there is no very clear answer to this question for the latest Node.js.

解决方案

Here's how I successfully upgraded from v0.8.18 to v0.10.20 without any other requirements like brew etc, (type these commands in the terminal):

  1. sudo npm cache clean -f (force) clear you npm cache
  2. sudo npm install -g n install n (this might take a while)
  3. sudo n stable upgrade to the current stable version

Note that sudo might prompt your password.

Additional note regarding step 3: stable can be exchanged for latest, lts (long term support) or any specific version number such as 0.10.20.

If the version number doesn't show up when typing node -v, you might have to reboot.

These instructions are found here as well: davidwalsh.name/upgrade-nodejs
More info about the n package found here: npmjs.com/package/n
More info about Node.js' release schedule: github.com/nodejs/Release

这篇关于在 Mac OS 上将 Node.js 升级到最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆