我应该使用包管理器还是从源代码在 Ubuntu 上安装 node.js? [英] Should I install node.js on Ubuntu using package manager or from source?
问题描述
有谁知道从源代码安装最新版本是否是一条冒险的路线?我应该坚持使用包管理器吗?
Does anyone know if installing the latest build from source is a risky route to take? Should i just stick with the package manager?
推荐答案
当前推荐
- 如果您想使用您的用户帐户进行安装,请使用 nvm.(我个人更喜欢这个)
- 按照此处的说明进行操作 使用 PPA 通过
apt
安装. - Use nvm if you want to install with your user account. (I personally prefer this)
- Follow the directions here to install via
apt
using a PPA.
Current recommendations
注意:在撰写本文时,我使用的是 Ubuntu 12.10.
Note: At the time of this writing I'm using Ubuntu 12.10.
安装node的方法有很多种.我个人更喜欢下载最新稳定版本的源代码,然后将其安装到 ~/local
(您可以通过将 --prefix
添加到 ./configure
命令,如此处所示.确实没有任何风险"这样做是因为所有内容都安装在与系统其余部分分开的目录中.您可以查看我的系统安装脚本中的节点配方 此处.我定期运行我的 update_node.py
脚本以将我的安装升级到最新版本.
There are a lot of ways to install node. I personally prefer to download the source of the latest stable build and just install it to ~/local
(you do this by adding --prefix
to the ./configure
command as seen here. There really isn't any 'risk' in doing this as everything gets installed in a directory which is separated from the rest of your system. You can have a look at the node recipe in my system install scripts here. I regularly run my update_node.py
script to upgrade my installation to the latest version.
或者,您可以按照此处的说明 通过包管理器安装最新的稳定版本.我实际上并没有这样做,所以我无法评论它的效果如何.
Alternatively you can follow the directions here to install the latest stable version via the package manager. I haven't actually done that so I can't comment on how well it works.
我不会从 ubuntu Universe 包安装节点.您最终会得到一个非常过时的版本(目前是 0.6.19).
What I wouldn't do is install node from the ubuntu universe packages. You'll end up with a very dated version (currently 0.6.19).
2013 年 1 月 26 日更新:
如果您有兴趣使用您的用户(非 root)帐户安装节点,我强烈建议您阅读 this 博客文章.我跳过了 ~/.npmrc
步骤,但发现 ~/.node_modules
符号链接步骤对于让 require
正常工作至关重要.
If you are interested in installing node with your user (non-root) account, I highly recommend reading this blog post. I skipped the ~/.npmrc
step, but found that the ~/.node_modules
symlink step was critial for getting require
to work properly.
2014 年 12 月 30 日更新:
我已迁移到使用 linux mint 并进行二进制节点安装.如果您有兴趣编写自己的安装脚本,可以在此处找到我当前的安装脚本.具体看看我在 node.sh.execute
函数在第一次安装时运行,所以它会做一些事情,比如在 .bashrc
中配置路径.install
函数由 update- 运行node.sh 用于删除现有安装并添加新安装(最新版本或用户指定的版本).
I have migrated to using linux mint and doing binary node installs. If you have any interest in writing your own installation scripts, you can find my current one here. Specifically have a look at what I'm doing in node.sh. The execute
function is run during the first install so it does things like configure the paths in .bashrc
. The install
function is run by update-node.sh and is used to remove an existing installation and add a new one (the latest version or one specified by the user).
2016 年 1 月 8 日更新:
我刚刚改用 nvm.只需安装脚本,然后运行 nvm install node
即可获得最新版本.这似乎是使用您的用户帐户安装节点的绝佳方式.
I just switched over to using nvm. Simply install the script and then run nvm install node
to get the latest version. This seems like an excellent way to get node installed with your user account.
这篇关于我应该使用包管理器还是从源代码在 Ubuntu 上安装 node.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!