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

查看:104
本文介绍了在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 -g n安装 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天全站免登陆