我应该使用包管理器还是从源代码在Ubuntu上安装node.js?

时间:2021-11-01 18:33:28

Does anyone know if installing the latest build from source is a risky route to take? Should i just stick with the package manager?

有没有人知道从源代码安装最新版本是一条冒险的路线?我应该坚持使用包管理器吗?

3 个解决方案

#1


26  

Current recommendations

  • Use nvm if you want to install with your user account. (I personally prefer this)
  • 如果要使用您的用户帐户安装,请使用nvm。 (我个人更喜欢这个)
  • Follow the directions here to install via apt using a PPA.
  • 按照此处的说明使用PPA通过apt安装。

Old Answer

Note: At the time of this writing I'm using Ubuntu 12.10.

注意:在撰写本文时,我使用的是Ubuntu 12.10。

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.

有很多方法可以安装节点。我个人更喜欢下载最新的稳定版本的源代码,然后将其安装到〜/ local(你可以通过在./configure命令中添加--prefix来实现这一点。如此处所示。实际上没有任何'风险'这一切都安装在一个与系统其他部分分开的目录中。你可以在这里查看系统安装脚本中的节点配方。我经常运行update_node.py脚本将我的安装升级到最新版本。

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.

或者,您可以按照此处的说明通过包管理器安装最新的稳定版本。我实际上没有这样做,所以我不能评论它的工作情况。

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).

我不会做的是从ubuntu Universe包中安装节点。你最终会得到一个非常过时的版本(目前为0.6.19)。

update 1/26/2013:

更新2013年1月26日:

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.

如果您有兴趣使用您的用户(非root)帐户安装节点,我强烈建议您阅读此博客文章。我跳过了〜/ .npmrc步骤,但发现〜/ .node_modules符号链接步骤对于要求正常工作是至关重要的。

update 12/30/2014:

2014年12月30日更新:

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).

我已经迁移到使用linux mint并进行二进制节点安装。如果您有兴趣编写自己的安装脚本,可以在此处找到我当前的安装脚本。具体来看看我在node.sh中做了什么。 execute函数在第一次安装期间运行,因此它可以在.bashrc中配置路径。 install函数由update-node.sh运行,用于删除现有安装并添加新安装(最新版本或用户指定的版本)。

update 1/8/2016:

2016年1月8日更新:

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.

我刚切换到使用nvm。只需安装脚本,然后运行nvm install node即可获得最新版本。这似乎是使用您的用户帐户安装节点的绝佳方式。

#2


6  

another option is nvm (Node Version Manager) : https://github.com/creationix/nvm

另一种选择是nvm(节点版本管理器):https://github.com/creationix/nvm

bonus that it lets you easily switch between versions.

它让你可以轻松地在版本之间切换。

#3


1  

Although I live in an .rpm, and not .deb realm, fpm can do both (needs Ruby installed). I have been able to package node.js from the latest stable source without any major difficulties. In your case, the following scenario may help:

虽然我住的是.rpm,而不是.deb领域,但fpm可以同时做两件事(需要安装Ruby)。我已经能够从最新的稳定源包装node.js而没有任何重大困难。在您的情况下,以下方案可能会有所帮助:

./configure --prefix=/usr
make
mkdir -p /tmp/nodejs
make install DESTDIR=/tmp/nodejs
fpm -s dir -t deb -n nodejs -v 0.8.15 -p nodejs-0.8.15.deb -C /tmp/nodejs usr

#1


26  

Current recommendations

  • Use nvm if you want to install with your user account. (I personally prefer this)
  • 如果要使用您的用户帐户安装,请使用nvm。 (我个人更喜欢这个)
  • Follow the directions here to install via apt using a PPA.
  • 按照此处的说明使用PPA通过apt安装。

Old Answer

Note: At the time of this writing I'm using Ubuntu 12.10.

注意:在撰写本文时,我使用的是Ubuntu 12.10。

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.

有很多方法可以安装节点。我个人更喜欢下载最新的稳定版本的源代码,然后将其安装到〜/ local(你可以通过在./configure命令中添加--prefix来实现这一点。如此处所示。实际上没有任何'风险'这一切都安装在一个与系统其他部分分开的目录中。你可以在这里查看系统安装脚本中的节点配方。我经常运行update_node.py脚本将我的安装升级到最新版本。

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.

或者,您可以按照此处的说明通过包管理器安装最新的稳定版本。我实际上没有这样做,所以我不能评论它的工作情况。

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).

我不会做的是从ubuntu Universe包中安装节点。你最终会得到一个非常过时的版本(目前为0.6.19)。

update 1/26/2013:

更新2013年1月26日:

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.

如果您有兴趣使用您的用户(非root)帐户安装节点,我强烈建议您阅读此博客文章。我跳过了〜/ .npmrc步骤,但发现〜/ .node_modules符号链接步骤对于要求正常工作是至关重要的。

update 12/30/2014:

2014年12月30日更新:

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).

我已经迁移到使用linux mint并进行二进制节点安装。如果您有兴趣编写自己的安装脚本,可以在此处找到我当前的安装脚本。具体来看看我在node.sh中做了什么。 execute函数在第一次安装期间运行,因此它可以在.bashrc中配置路径。 install函数由update-node.sh运行,用于删除现有安装并添加新安装(最新版本或用户指定的版本)。

update 1/8/2016:

2016年1月8日更新:

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.

我刚切换到使用nvm。只需安装脚本,然后运行nvm install node即可获得最新版本。这似乎是使用您的用户帐户安装节点的绝佳方式。

#2


6  

another option is nvm (Node Version Manager) : https://github.com/creationix/nvm

另一种选择是nvm(节点版本管理器):https://github.com/creationix/nvm

bonus that it lets you easily switch between versions.

它让你可以轻松地在版本之间切换。

#3


1  

Although I live in an .rpm, and not .deb realm, fpm can do both (needs Ruby installed). I have been able to package node.js from the latest stable source without any major difficulties. In your case, the following scenario may help:

虽然我住的是.rpm,而不是.deb领域,但fpm可以同时做两件事(需要安装Ruby)。我已经能够从最新的稳定源包装node.js而没有任何重大困难。在您的情况下,以下方案可能会有所帮助:

./configure --prefix=/usr
make
mkdir -p /tmp/nodejs
make install DESTDIR=/tmp/nodejs
fpm -s dir -t deb -n nodejs -v 0.8.15 -p nodejs-0.8.15.deb -C /tmp/nodejs usr