Last active
February 9, 2016 01:48
-
-
Save codeopensrc/ebd10a129c935e058567 to your computer and use it in GitHub Desktop.
Install node java package on Raspberry Pi 2 B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Because I'm not entirely sure if all the previous steps were needed or only the final one, I included other problems | |
# that may cause the node-gyp rebuild to fail during java installation (or bcrypt throwing install errors) | |
# This assumes you are using 7.8 "wheezy" | |
# More information regarding other distros: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions | |
# Use the correct node version for the Raspberry ARM architecture: | |
# https://stackoverflow.com/questions/32563173/installing-node-js-on-raspberry-pi-2 | |
wget http://yourARMarchitecurelink | |
cd /usr/local | |
sudo tar xzvf path/to/tarfile/yournodeversion.tar.gz --strip=1 | |
# If its .tar.xz remove the -z flag from tar | |
# If you don't have `make` already | |
sudo apt-get update && sudo apt-get upgrade | |
sudo apt-get install build-essential | |
# Make sure you have gcc 4.8 and g++ 4.8, as its required for the latest node/node-gyp (4.0+ ?) | |
# https://stackoverflow.com/questions/33532528/nodejs-4-5-npm-install-fail-for-bcrypt-and-db-migrate | |
# I only had to do the 2 steps: | |
# If you had `make` and didnt already: sudo apt-get update && sudo apt-get upgrade | |
# NOTE THE BELOW MAY NOT BE THE BEST WAY, BUT IN THE END IT WORKED FOR ME | |
# I tried doing update-alternatives, but in the end I removed gcc and gcc 4.8 and started fresh | |
sudp apt-get remove gcc | |
sudo apt-get install gcc-4.8 g++-4.8 | |
sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc | |
sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++ | |
# Or instead of symlinking (if you know what youre doing) | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 | |
# For me, jdk8 worked | |
sudo apt-get install oracle-java8-jdk | |
# Use python 2.7 when installing node-gyp/java package (also in node-gyp README): | |
# https://stackoverflow.com/questions/20454199/how-to-use-a-different-version-of-python-during-npm-install | |
npm config set python python2.7 | |
# And finally thanks to: https://github.com/joeferner/node-java/issues/179 & https://github.com/joeferner/node-java/pull/256 | |
# The `gyp: Undefined variable javalibdir in binding.gyp while trying to load binding.gyp` was my main source | |
# of anguish, which the below command fixed (which is a slight modification from the npm java README) | |
# DEPENDING ON MANY VARIABLES, TRY ANY ONE OF THE 4 METHODS MENTIONED IN URL. It took several trys to find the right combination: | |
GYP_DEFINES="armv7=0 javalibdir=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/lib/arm/server/" CCFLAGS='-march=armv6' CXXFLAGS='-march=armv6' npm install java | |
# Hope this helps! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment