9

I'm trying to get nodejs and npm installed on centos 7

So first I did rpm -i http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm to get the epel repository

Then I tried yum install nodejs. Which worked. Then I tried yum install npm. Yum returns with "npm package not found"

Will I have to build npm manually? And how should I do that?

Chris
  • 91
  • 1
  • 1
  • 3

8 Answers8

13

I just re-checked this. Both nodejs and npm and all dependencies for both have been added to epel 7. I just installed both on my CentOS 7 box. You should be able to do:

yum -y install nodejs npm

The -y flag will automatically answer "yes" to every confirmation question, so leave it out if you want to be able to say no to something.

wbr
  • 131
  • 2
  • 3
    January 2015 here. Centos 7.0.1406 with EPEL 7-5, npm installs and then promptly breaks itself and the system (`/usr/bin/which` is where it dies for me) if you `npm update -g`. I can't figure out what's wrong, but I would advise building node/npm from source. – Steven Lu Jan 28 '15 at 08:52
9

On Centos 7, for installation of npm and nodejs, follow these steps

1. Open terminal
2. Run these commands (With sudo or root)

yum install epel-release
yum install npm nodejs
8

NPM isn't packaged for EPEL 7 yet. Give it some time, they are having to update thousands of packages already and had to wait for the CentOS release which was just a couple of days ago.

I suggest contacting the package maintainer (who appears to be patches) as they may not be aware that CentOS 7 is released and that they can now build their packages for it.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • As an aside, one can easily package npm on one's own with [fpm](https://github.com/jordansissel/fpm). Almost no expertise required. – Deer Hunter Jul 11 '14 at 04:06
8

curl -L https://npmjs.org/install.sh | sh

I found this here: https://www.npmjs.org/doc/README.html#fancy-install-unix-

I tried it on a fresh CentOS 7 install and it works!

1

I have make a copr repository which provide the latest (sync with the Fedora rawhide) NodeJs and NPM. It also contains the build dependencies should you want to rebuild it.

Note that to build the latest NPM, you need openssl >=1.0.2, but EL7 only provide 1.0.1. So if you don't want to update the openssl to 1.0.2, please append exclude=openssl* to the end of /etc/yum.repos.d/dchen-nodejs-epel-7.repo

Ding-Yi Chen
  • 111
  • 4
0

Here's another option -

yum install rpmbuild
wget http://dl.fedoraproject.org/pub/epel/6/SRPMS/npm-1.3.6-5.el6.src.rpm
rpmbuild --rebuild npm-1.3.6-5.el6.src.rpm
yum install /path/to/npm/rpm

mind you - I don't have access to centos 7 machine right now, so can't test. usually the build will go without any issues, or minor ones that can be solved easily by modification of the .spec file and nothing else

Dani_l
  • 498
  • 2
  • 8
  • This doesn't really seem to work. While the package compiles fine, it has lots of dependencies to packages that are currently missing from EPEL 7. – lhahne Jul 16 '14 at 13:21
  • And thus you start the adventure that is rpm hell... If you really need it now, install from source (the "./configure;make;make install" route). otherwise - either wait or start rebuilding and fixing source rpms for all dependencies. If you feel charitable, you can later donate your work back to epel. – Dani_l Jul 16 '14 at 17:54
0

Use this:

https://github.com/kazuhisya/nodejs-rpm

Once you create RPMs using these instructions, you must do the installation of created RPMs with --force (there is a conflict on node man page, just ignore it).

I confirm that it works on CentOS 7.

Tomy
  • 66
  • 1
  • 4
0

Another efective but very easy way to install Node.js on your machine is to do it from the official repository. To this make sure you have access to to the EPEL repository, you can do this by running the following command.

sudo yum install epel-release

Now use the yum command to install Node.js

sudo yum install nodejs

And since I want to manage node packages during the development I also need to install the npm package manager for Node.js by using the following command.

sudo yum install npm

Please check this Link for more details