hi all,
so you may have run into some problems installing node.js from source with the arch linux image.
yes, i am aware you can use Arch's pacman package manager to install node.js and npm, but those tend to name them nodejs on the command line, not the standard node and then you get into a whole other how-to on fixing that. i prefer my node compiled from source and ready to go the way i expect it.
so i thought i'd put together this how-to for those who may have run into similar difficulties.
the short, tl;dr —
Arch Linux has python 3.5.1 installed (at least on the image we are using for Pine64 boards). make, node.gyp and the JavaScript V8 engine depend on python 2.7.x.
so do this —
install python2 to Arch Linux using —
from the command in your home directory do:
...then, switch to the directory where you've downloaded and decompressed the node.js source and do —
voila! you got node! test it out with —
...and — profit! ? ? ?
the long version —
for background, check out this node.js issue on github, #2735, as well as the issue they all point to and reference, #418, as well as the issue i filed, #6249.
basically, it comes down to this — Arch Linux installs only Python v3.5.1, and the JavaScript V8 engine (maintained by Google's The Chromium Project), as well as Node.js' node.gyp and the script files for the build all want to use Python 2.7.x. If you go into script files for the node install like the configure file, you'll see that at top, it says —
now you could use Arch Linux's pacman (similar to deb repositories and apt in Ubuntu and rpm in RedHat) package installer to install Python 2.7.x change this to —
...and that would work for a bit with the configure file, but would fail the moment anything is required of node.gyp or the V8 engine, as they have hard coded stuff in them for python which defaults to the OS' python default install, which in Arch Linux is Python 3.5.1.
so over that issue for node.js, @rvagg suggests the following —
this will create a node source install directory in your Downloads folder. you can go ahead and delete the compressed node.js source file now.
this creates a directory under your home directory that is "bin," you create a symbolic link from there to your python2 for installing, then you export that to your $PATH statement.
... and voila, you got node!
...which should return, now, both the version numbers for node.js and npm.
...and — profit! ? ? ?
best,
— faddah
portland, oregon, u.s.a.
so you may have run into some problems installing node.js from source with the arch linux image.
yes, i am aware you can use Arch's pacman package manager to install node.js and npm, but those tend to name them nodejs on the command line, not the standard node and then you get into a whole other how-to on fixing that. i prefer my node compiled from source and ready to go the way i expect it.
so i thought i'd put together this how-to for those who may have run into similar difficulties.
the short, tl;dr —
Arch Linux has python 3.5.1 installed (at least on the image we are using for Pine64 boards). make, node.gyp and the JavaScript V8 engine depend on python 2.7.x.
so do this —
install python2 to Arch Linux using —
Code:
pacman -S python2
from the command in your home directory do:
Code:
mkdir -p ~/bin/
ln -s $(which python2) ~/bin/python
export PATH=~/bin/:$PATH
...then, switch to the directory where you've downloaded and decompressed the node.js source and do —
Code:
cd /path/to/where/your/node.js-source-is/
./configure
make
sudo make install
voila! you got node! test it out with —
Code:
node -v
npm -v
...and — profit! ? ? ?
the long version —
for background, check out this node.js issue on github, #2735, as well as the issue they all point to and reference, #418, as well as the issue i filed, #6249.
basically, it comes down to this — Arch Linux installs only Python v3.5.1, and the JavaScript V8 engine (maintained by Google's The Chromium Project), as well as Node.js' node.gyp and the script files for the build all want to use Python 2.7.x. If you go into script files for the node install like the configure file, you'll see that at top, it says —
Code:
#!/usr/bin/env python
now you could use Arch Linux's pacman (similar to deb repositories and apt in Ubuntu and rpm in RedHat) package installer to install Python 2.7.x change this to —
Quote:#!/usr/bin/env python2
...and that would work for a bit with the configure file, but would fail the moment anything is required of node.gyp or the V8 engine, as they have hard coded stuff in them for python which defaults to the OS' python default install, which in Arch Linux is Python 3.5.1.
so over that issue for node.js, @rvagg suggests the following —
- install Python 2.7.x to your Arch Linux install using the pacman package manager —
Code:
pacman -S python2
- download your node.js install to compile from source for linux, which you can do on the nodejs.org site, or here on the particular node.js distriubtion version page.
- i downloaded mine to the Downloads directory under my home directory, or ~/Downloads/
- decompress the node.js source file using —
Code:
tar xvf node-vX.X.X-tar.xz
this will create a node source install directory in your Downloads folder. you can go ahead and delete the compressed node.js source file now.
- switch to your home directory
Code:
cd ~
- run the following in the command line —
Code:
mkdir -p ~/bin/
ln -s $(which python2) ~/bin/python
export PATH=~/bin/:$PATH
this creates a directory under your home directory that is "bin," you create a symbolic link from there to your python2 for installing, then you export that to your $PATH statement.
- now switch back to the directory that has your node.js source install, and run the following —
Code:
cd /path/to/where/your/node.js-source-is/
./configure
make
sudo make install
... and voila, you got node!
- now test it out using —
Code:
node -v
npm -v
...which should return, now, both the version numbers for node.js and npm.
...and — profit! ? ? ?
best,
— faddah
portland, oregon, u.s.a.