在linux中使用包管理器安装node.js
网上文章中,在linux下安装node.js都是使用源码编译,其实node的github上已经提供了各个系统下使用各自的包管理器(packagemanager)安装node.js的方法。
1.在Ubuntu中,使用如下命令:
curl-sLhttps://deb.nodesource.com/setup|sudobash- sudoapt-getinstall-ynodejs
如果需要使用npm安装本地组件,还需要执行如下命令:
apt-getinstall-ybuild-essential
2.在Debian中,使用如下命令:
apt-getinstallcurl curl-sLhttps://deb.nodesource.com/setup|bash- apt-getinstall-ynodejs
如果需要使用npm安装本地组件,还需要执行如下命令:
apt-getinstall-ybuild-essential
3.在RHEL、Fedora、CentOS中,使用如下命令:
curl-sLhttps://rpm.nodesource.com/setup|bash- yuminstall-ynodejs
如果需要使用npm安装本地组件,还需要执行如下命令:
yumgroupinstall'DevelopmentTools' #下面这行是在Fedora中执行的 sudoyuminstallnodejsnpm #下面这行是在RHEL和CentOS中执行的 sudoyuminstallnodejsnpm--enablerepo=epel
不过实践中,在CentOS6中,执行
sudoyuminstallnodejsnpm--enablerepo=epel
会报错,而不执行,也可以使用npm。
4.在openSUSE和SLE中,使用如下命令:
sudozypperar\ http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/\ Node.js sudozypperinnodejsnodejs-devel
5.在ArchLinux中,使用如下命令:
pacman-Snodejs
6.在FreeBSD和OpenBSD中,使用如下命令:
/usr/ports/www/node cd/usr/ports/www/node-devel/&&makeinstallclean #或者 pkg_add-rnode-devel pkginstallnode #或者 pkginstallnode-devel
以上就是本文的全部内容了,希望大家能够喜欢。