Node.js

Like the horde before me, I have been following Node.js developments for several months and its exploding ecosystem is too fascinating to ignore. When I added Microsoft’s Visual Studio code and TypeScript, I can clearly see many compelling uses for it on both server and browser side development.

While Fedora repository packaging of Node.js works as any other easy install, I recommend not using it beyond the tutorial phase with this development stack. In fact, it’s rather trivial to download, install, and maintain without RPM. After downloading Google’s “For Most Users” binaries, here I will share a convenience script to complete that process:

#!/bin/sh

nodejs=$1
sudo -v
cd /opt

if [ -z "$nodejs" ]; then
    for nodejs in `find ~/Downloads/node-v*.xz`; do
        echo $nodejs
    done
    [ -f "$nodejs" ] && xz -d $nodejs

    for nodejs in `find ~/Downloads/node-v*.tar`; do
        echo $nodejs
    done

    pathto=`dirname $nodejs`
    tar=`basename ${nodejs}`
    folder=${tar%.*}

    sudo tar xf $pathto/$tar
    [ -d $folder ] || exit 1
    sudo chown -R root.games $folder
    find $folder -type d -exec sudo chmod g+s {} \;
else
    [ -d $nodejs ] || exit 1
    folder=$nodejs
fi

sudo rm -fv node
sudo ln -s $folder node
ls -l
cd -

npm install typescript -g
npm upgrade

echo "Node.js `node -v`"
echo "npm `npm -v`"
echo "TypeScript `tsc -v`"

A quick note: I tend to configure my development workstation like a server, which is why I opt to install in /opt for any user or process to have access. And also not necessary for development, I make myself a member of games and make it so I can have furhter write access into the release tree without sudo. Then, I put a simple system configuration file as /etc/profile.d/node.sh:

#!/bin/sh
export PATH=$PATH:/opt/node/bin