Error installing Nodejs on CentOS 5 server - no module bz2 - node.js

I'm trying to get NodeJS installed on my CentOS 5 server
I got Python 2.6 installed, and I got ./configure to work, but when I run the make command 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

I, too, got the same error as Marius Milliunas when I ran make on Centos 6.4 - That was after I ran the ./configure command in the nodejs directory, which I had extracted from the downloaded nodejs tarball. Just as Marius Milliunas did.
The root of the problem is that the nodejs installation relies on Python being installed. Specifically, the default Python installation for Centos 6.4 does NOT include the bz2 module and corrective action, of course, starts with installing 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 that's fine for the purpose of installing the latest version of nodejs, which as of this writing is node v0.10.26
Once you have run yum install bzip2-devel , you can go back and run make in the nodejs directory and this time, make will run to completion. Follow up by running make install as per the instructions set in the nodejs directory.
You can test your nodejs installation by running node and getting the prompt. I chose to test by creatind 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 all was cool with the world and that I had properly 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 "It works" output, as expected :)
Important Note
If you are additionally installing Python 2.7.6 and Python 3.3.4 on the Centos 6.4 machine, follow the instructions on 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.3is purely optional. Note that the last step of 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 system Python, which is Python 2.6.6, and my access to yum. In fact, I surmise that I destroyed my access to every program on Centos 6.4 that relies on access to system Python to work properly. If I had successfully installed nodejs by that point in time, I would have destroyed my access to nodejs, too. I had to destroy and recreate /usr/local/bin/python2 as the soft link to /usr/local/bin/python2.6 and do the same with /usr/bin/python2 to get things back to normal. Not much fun.

Note that another solution to this issue (unable to compile node.js) is to use the binary distributions for Linux which 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

Related

NodeJS on Windows 10 and Windows Subsystem for Linux

I'm trying to get Expo, a platform for making native mobile apps, to run on a Windows 10 machine. A preprequisite for Expo is NodeJS so I installed that. However, I ran into some issues getting Expo to work using Git Bash and so now I'm trying to get Windows Subsystem for Linux (WSL) operational to use that instead. Ubuntu 18.04 LTS has been downloaded and initialized. Using a CMD here is what's happening:
C:\Users\jason.black>node -v
v12.13.0
C:\Users\jason.black>wsl
jason#PC1:/mnt/c/Users/jason.black$ node -v
Command 'node' not found, but can be installed with:
sudo apt install nodejs
jason#PC1:/mnt/c/Users/jason.black$ sudo apt install nodejs
[sudo] password for jason:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nodejs
jason#PC1:/mnt/c/Users/jason.black$
So it appears that NodeJS which was initially installed is not available to WSL. Does that seem right? And why won't it install so WSL can access it?
If you're trying to access Node installed on the windows site, you may specify the PATH to /mnt/x/.../path/to/node/bin; if you're trying to install nodejs on the Linux side, may be you're looking for the package 'node' (not nodejs), or you can just download the portable version: https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
For someone who's not familiar to Linux:
# will be download to home directory
cd ~
# using wget
wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
# using curl
curl -o node-v12.13.1-linux-x64.tar.xz https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
# extract
tar xf node-v12.13.1-linux-x64.tar.xz

Installing nodeJs in ubuntu

Hi I am trying to install nodejs in ubuntu 14 but getting following error.
E: Cannot get debconf version. Is debconf installed?
debconf: apt-extracttemplates failed: No such file or directory
Extracting templates from packages: 62%E: Cannot get debconf version. Is debconf installed?
debconf: apt-extracttemplates failed: No such file or directory
Extracting templates from packages: 100%
dpkg: cannot scan updates directory `/var/lib/dpkg/updates/': No such file or directory
E: Sub-process /usr/bin/dpkg returned an error code (2)
when trying to installing with software updated I am getting following error.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/aptdaemon/worker.py", line 300, in _process_transaction
not self.is_dpkg_journal_clean()):
File "/usr/lib/python3/dist-packages/aptdaemon/worker.py", line 1111, in is_dpkg_journal_clean
for dentry in os.listdir(status_updates):
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/dpkg/updates/'
I had this problem previously, I removed any variables equivalent to zero and it solved it, perhaps try that.
Add the Node.js-maintained repositories to your Ubuntu package source list with this command:
curl -sL https://deb.nodesource.com/setup | sudo bash -
Then install Node.js with apt-get:
sudo apt-get install nodejs
Optionally we can create a symbolic link for node (for reasons mentioned earlier):
sudo ln -s /usr/bin/nodejs /usr/bin/node
Using this install option, we end up with newer versions of Node.js and npm:
$ node -v
$ npm -v
to check node version and npm version
I suggest installing nvm (node version manager)
https://github.com/creationix/nvm
it allows you to install and use ANY node version, and this may be way better, because ubuntu is bound to one specific version. In web development, every project is prepared using dofferen node, so switching it might be necessary

Valgrind does not work with WSL?

When I installed WSL for my computer I was very excited to have a more natively supported Linux system rather than using VirtualBox. However I get this error when I try to run it. Is there a reason why?
I am happy to give more information as required.
--4364:0:aspacem -1: ANON 0038000000-00383d5fff 4022272 r-x-- SmFixed d=0x000 i=25365 o=0 (0) m=0 /usr/lib/valgrind/memcheck-amd64-linux
--4364:0:aspacem Valgrind: FATAL: aspacem assertion failed:
--4364:0:aspacem segment_is_sane
--4364:0:aspacem at m_aspacemgr/aspacemgr-linux.c:1502 (add_segment)
--4364:0:aspacem Exiting now.
It's definitely possible
I've encountered some problems installing it directly with apt, however it can be installed manually with some very simple steps:
Download the source file: wget http://valgrind.org/downloads/valgrind-3.12.0.tar.bz2 (by the time you read this there could be a newer version)
Extract the archive: tar -xvjf valgrind-3.12.0.tar.bz2
Configure the installation process: cd into the exctracted folder valgrind-3.12.0 and then launch ./configure
Make: simply launch make while in the valgrind-3.12.0 folder
Check the dependencies: launch make check to see whether all the dependencies necessary for the installation are satisfied (e.g: you'll have to install g++, just launch sudo apt install g++)
Install valgrind: type sudo make install to install it
I had the same problem, the solution was to install Windows 10 creators update (version 1703), and reinstall Bash/WSL. Valgrind now works fine :)

Installing after build phantomjs 2.0 on linux

i followed the instructions here: http://phantomjs.org/build.html then i build it on linux (ubuntu), after this i get on this point "This produces a build bin/phantomjs. This is an executable; it can be moved to a different directory (e.g. /usr/local/bin) or another machine."
Yes it's there, an executable, but how i install it now? i tried using the commands phantomjs on terminal, i only had succes if i install it trough the command sudo apt-get install phantomjs or sudo npm install phantomjs
after this i run the code phantomjs -v and get the version: 1.9
i tried to run my code with phantomjs 1.9 but he ask's for 2.0
and i dont know how to install this exec file or use it to install the phantomjs 2.0, already tried to execute the file by double clicking, and using the command ./phantomjs on the directory... Also tried to run like windows, you go to directory which is the .exe file and then run the command normal like, phantomjs code.js but i doesn't work.
Sorry for this newbie question, im new with linux, starting using it this week.

Step by step: Installing Python 3.3, Lighttpd & Pymongo on Ubuntu 12.04

I'm currently migrating to new computer and I need to reinstall the software I am using which are:
Python 3.3,
Lighttpd (newest version),
Pymongo (newest version),
Ubuntu 12.04 Desktop (The System I'm using)
I started to install Python 3.3 by downloading it from the its official website (in tar.bz2 file) and by following this tutorial. Afterwards I installed Lighttpd and changed the lighttpd.conf for Python by following this tutorial, too.
I tried several paths for my cgi.assign, none of them worked. Especially /opt/python3.3/bin/python3.3 should be working, but it shows 500 - internal Server error all the time with a "hello world" test script.
Now regardless to this problem I have no clue on installing Pymongo. If I try to intall pip OR easy_install python3.3 I have to manually download it and execute the setup.py with my python3.3 executable, right? Because this always fails with an error:
`Error missing zlib on a bundle called distribute-0.7.3 (is this even the right tool I need, because it seems to be a legacy wrapper !?) or unknown url type: https for pymongo2.6.2 itself.`
I'm getting crazy with this setup. Why is this so difficult to handle? Other programs are just a few clicks to install even on a system like Ubuntu, but these particular development tools seem to be really difficult to install.If anybody has an idea on how to install all three together or has information on a better solution please help me out.
The system is used to program Python scripts in Eclipse and trying them out directly on the system (lighttpd). The database used is MongoDB. Python and MongoDB are communicating over the Pymongo driver. I am planning to use the system on a Server distribution on release and it has to be nicely scalable on a high amount of excecutions.
Thanks for your time,
It's easiest to use the Ubuntu repositories:
sudo apt-get update
sudo apt-get install python3 python3-pip lightppd python-pymongo
Or if that only installs the python2.x pymongo, use pip, which you've just installed:
sudo pip-3.3 install pymongo
Or better yet, use a virtualenv with the help of virtualenvwrapper (docs)
sudo pip install virtualenvwrapper
... # follow instructions for installing virtualenvwrapper
mkvirtualenv --python=/usr/bin/python3 -i pymongo mongoppd
workon mongoppd
... which will segregate the environment I've called 'mongoppd' from the rest of your system so you can't cause any trouble. Then you don't need sudo to pip-3.3 install things, just workon mongoppd then pip-3.3 install [...]. Or after the -i flag when you create the virtualenv to get it installed straight away.
In general, on Ubuntu, you should hardly ever have to install something manually. Your first attempt should be using sudo apt-get install (use tab-complete to see what's available or just google "ubuntu 12.04 packages [...]" and you'll find the list of packages). Then for python use pip install or pip-3.3 install as appropriate. You'll only need to run python setup.py install if you need to install a development version of a package or something obscure that's not on pip. I don't think there's a good reason to ever use easy_install these days.

Resources