Error installing Nodejs on CentOS 5 server - no bz2 module

I am trying to install NodeJS on my CentOS 5 server

I have Python 2.6 installed and I got it. / configure to work, but when I run the make , I get this result

 [ root@catch24dev node-v0.8.6]# make make -C out BUILDTYPE=Release V=1 .... Traceback (most recent call last): File "../../tools/js2c.py", line 36, in <module> import bz2 ImportError: No module named bz2 make[1]: *** [/usr/local/src/node-v0.8.6/out/Release/obj/gen/libraries.cc] Error 1 make[1]: Leaving directory `/usr/local/src/node-v0.8.6/out' make: *** [node] Error 2 [ root@catch24dev node-v0.8.6]# which bzip2 /usr/local/bin/bzip2 
+4
source share
2 answers

I also got the same error as Marius Milliunas when I ran make on Centos 6.4 - This was after I ran the ./configure command in the nodejs directory that I extracted from the loaded tarjs. Just like Marius Milliunas did.

The root of the problem is that the installation of nodejs depends on the installed Python. In particular, the default Python installation for Centos 6.4 does NOT include the bz2 module, and, of course, corrective actions begin with the installation of the bz2 module. This is done by running

 yum install bzip2-devel 

I also ran for good measure

 yum install bzip2 

The built-in Python for Centos 6.4 is Python 2.6.6, but it is great for installing the latest version of nodejs, which at the time of this writing is node v0.10.26

Once you run yum install bzip2-devel , you can go back and run make in the nodejs directory, and this time it will be done. Run by running make install in accordance with the instructions given in the nodejs directory.

You can test the installation of nodejs by running node and receiving a prompt. I decided to test creatint on a nodejs based web server as described in http://code.tutsplus.com/tutorials/real-time-chat-with-nodejs-socketio-and-expressjs--net-31708

I knew that everything was cool with the world and that I correctly installed nodejs on Centos 6.4 when I followed this instruction

 The server is running, so you should be able to open http://127.0.0.1:3700/ and see: It works! 

and got the conclusion "It works", as expected :)

Important Note

If you are additionally installing Python 2.7.6 and Python 3.3.4 on a Centos 6.4 machine, follow the instructions at this link: https://www.digitalocean.com/community/articles/how-to-set-up-python-2- 7-6-and-3-3-3-on-centos-6-4

Installing Python 2.7.6 and Python 3.3 is optional. Note that the final step in installing Python 2.7.6 and Python 3.3.4 is

 make altinstall 

and NOT make install. I ran make install by mistake and destroyed my access to the Python system, which is Python 2.6.6, and my access to yum. In fact, I assume that I destroyed my access to every Centos 6.4 program that relies on access to the Python system to work properly. If I managed to install nodejs at this point in time, I would also destroy my access to nodejs. I had to destroy and recreate / usr / local / bin / python 2 as a soft link to / usr / local / bin / python 2.6 and do the same with / usr / bin / python 2 to return to normal. Not a lot of fun.

+3
source

Note that another solution to this problem (unable to compile node.js) is to use the binary distributions for Linux that have been published since 0.8. 6

Here's the script I used:

 # get the latest stable binary # (modify version number based on what you find in that folder) wget http://nodejs.org/dist/latest/node-v0.8.20-linux-x64.tar.gz cd /usr/local/ sudo tar xzvf ~/node-v0.8.20-linux-x64.tar.gz --strip=1 
+3
source

All Articles