Last active
January 9, 2022 13:44
-
-
Save lackdaz/15f929aeb0fee44369af1d96635769b8 to your computer and use it in GitHub Desktop.
Installs node and yarn on an arm64 (armv8) OS (Jetson Nano)
This file contains hidden or 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
#!/bin/bash | |
set -e | |
## Check for versions compiled with ARM at http://nodejs.org/dist/ | |
## Inspired by http://oskarhane.com/raspberry-pi-install-node-js-and-npm/ | |
## Fill in the Node Version here: | |
########################################################################## | |
NODE_VERSION="v12.16.1" | |
########################################################################## | |
#Get it | |
wget http://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-arm64.tar.xz | |
#unpack | |
tar -xf node-${NODE_VERSION}-linux-arm64.tar.xz | |
mkdir /opt/node | |
#Copy to the dir you made as the first step | |
cp -rf node-${NODE_VERSION}-linux-arm64/* /opt/node | |
rm -rf node-${NODE_VERSION}-linux-arm64* | |
#Add node to your path so you can call it with just "node" | |
#Add these lines to the file you opened | |
EXPORT_PATH="export PATH=\$PATH:/opt/node/bin" | |
if ! grep -Fx "$EXPORT_PATH" ~/.profile >/dev/null 2>/dev/null; then | |
echo "Updating" ~/.profile | |
echo >> ~/.profile # add newline | |
echo "$EXPORT_PATH" >> ~/.profile | |
fi | |
source ~/.profile | |
# linking for sudo node (TO FIX THIS - NODE DOES NOT NEED SUDO!!) | |
ln -fns /opt/node/bin/node /usr/bin/node | |
ln -fns /opt/node/lib/node /usr/lib/node | |
ln -fns /opt/node/bin/npm /usr/bin/npm | |
ln -fns /opt/node/bin/node-waf /usr/bin/node-waf | |
#Test | |
if ! [ -x "$(command -v node)" ]; then | |
echo 'Error: node did not install properly' >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v npm)" ]; then | |
echo 'Error: npm did not install properly' >&2 | |
exit 1 | |
fi | |
echo "installed node@$(node -v)" | |
echo "installed npm@$(npm -v)" | |
# Install Yarn | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
apt update && apt -y install yarn | |
EXPORT_PATH="export PATH=\$PATH:/opt/yarn-[version]/bin" | |
if ! grep -Fx "$EXPORT_PATH" ~/.profile >/dev/null 2>/dev/null; then | |
echo "Updating" ~/.profile | |
echo >> ~/.profile # add newline | |
echo "$EXPORT_PATH" >> ~/.profile | |
fi | |
source ~/.profile | |
#Test | |
if ! [ -x "$(command -v yarn)" ]; then | |
echo 'Error: yarn did not install properly' >&2 | |
exit 1 | |
fi | |
echo "installed yarn@$(yarn -v)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment