Node.jsĀ® is a JavaScript runtime built on Chrome’s V8 JavaScript engine which uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. As an asynchronous event driven framework, Node.js is designed to build scalable network applications.
The following procedure installs Node.js on CentOS7 and should work fine on CentOS/RHEL5,6 and Fedora:
1. Download the Node.js repo setup script
[root@rhel7master ~]# wget https://rpm.nodesource.com/setup .
- 2. Change permission to be able to execute the script
[root@rhel7master ~]# chmod +x setup
3. Install repo
[root@rhel7master ~]# ./setup ## Installing the NodeSource Node.js 0.10 repo... ## Inspecting system... + rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release + uname -m ## Confirming "el7-x86_64" is supported... + curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm' ## Downloading release setup RPM... + mktemp + curl -sL -o '/tmp/tmp.BWT4pCZ7VN' 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm' ## Installing release setup RPM... + rpm -i --nosignature --force '/tmp/tmp.BWT4pCZ7VN' ## Cleaning up... + rm -f '/tmp/tmp.BWT4pCZ7VN' ## Checking for existing installations... + rpm -qa 'node|npm' | grep -v nodesource ## Run `apt-get install nodejs` (as root) to install Node.js 0.10 and npm ## Run `yum install -y nodejs` (as root) to install Node.js 0.10 and npm. ## You may also need development tools to build native addons: ## `yum install -y gcc-c++ make`
4. Install Node.js
[root@rhel7master ~]# yum install nodejs -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: www.mirrorservice.org * extras: centos.mirroring.pulsant.co.uk * updates: www.mirrorservice.org Resolving Dependencies --> Running transaction check ---> Package nodejs.x86_64 0:0.10.41-1nodesource.el7.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: nodejs x86_64 0.10.41-1nodesource.el7.centos nodesource 4.5 M Transaction Summary ================================================================================ Install 1 Package Total download size: 4.5 M Installed size: 16 M Downloading packages: warning: /var/cache/yum/x86_64/7/nodesource/packages/nodejs-0.10.41-1nodesource.el7.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 34fa74dd: NOKEY Public key for nodejs-0.10.41-1nodesource.el7.centos.x86_64.rpm is not installed nodejs-0.10.41-1nodesource.el7.centos.x86_64.rpm | 4.5 MB 00:16 Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL Importing GPG key 0x34FA74DD: Userid : "NodeSource <gpg-rpm@nodesource.com>" Fingerprint: 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd Package : nodesource-release-el7-1.noarch (installed) From : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : nodejs-0.10.41-1nodesource.el7.centos.x86_64 1/1 Verifying : nodejs-0.10.41-1nodesource.el7.centos.x86_64 1/1 Installed: nodejs.x86_64 0:0.10.41-1nodesource.el7.centos Complete!
5. Update npm version to latest
[root@rhel7master ~]# npm -g install npm@latest npm WARN deprecated This version of npm lacks support for important features, npm WARN deprecated such as scoped packages, offered by the primary npm npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the npm WARN deprecated latest stable version. To upgrade to npm@2, run: npm WARN deprecated npm WARN deprecated npm -g install npm@latest-2 npm WARN deprecated npm WARN deprecated To upgrade to the latest stable version, run: npm WARN deprecated npm WARN deprecated npm -g install npm@latest npm WARN deprecated npm WARN deprecated (Depending on how Node.js was installed on your system, you npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if npm WARN deprecated on Windows, run them from an Administrator prompt.) npm WARN deprecated npm WARN deprecated If you're running the version of npm bundled with npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS npm WARN deprecated will be bundled with a version of npm@2, which has some small npm WARN deprecated backwards-incompatible changes made to `npm run-script` and npm WARN deprecated semver behavior. /usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js npm@3.5.2 /usr/lib/node_modules/npm
6. Check Node.js version
[root@rhel7master ~]# node -v v0.10.41
[root@rhel7master tmp]# npm -v 3.5.2
1 Comment