This is sort of a cool (yet annoying) way of installing NodeJS.
If you run
tar tf /usr/save/node-v4.2.1-linux-x64.tar.gz on the file, you'll see something like this:
Basically, this means that when you extract this tar archive, it'll extract to a folder called
node-v4.2.1-linux-x64 with all of these subfolders (and the node installation) inside of it. In fact, you can even try this extraction to get a better idea:
tar xvf /usr/save/node-v4.2.1-linux-x64.tar.gz
If you run
ls, you'll see a
--strip-components 1 does something interesting to the extraction process. From
strip NUMBER leading components from file names on extraction
Basically, this means that when
tar is going to extract your archive, it's going to pretend like the
node-v4.2.1-linux-x64 folder isn't there. Instead, it's going to extract
share/ and all the other folders directly.
In fact, you can try it:
tar xvf /usr/save/node-v4.2.1-linux-x64.tar.gz --strip-components=1
If you run
ls, you'll see there's no longer a
node-v4.2.1-linux-x64 folder. It's just
share/ (all coincidentally folders in
Your second command wouldn't have worked because it would have just extracted the
node-v4.2.1-linux-x64 folder to
/usr/local (if it even ran at all). If you run
ls /usr/local, you might even see this folder hanging around. It's useless, feel free to delete with
rm. As for why it's useless, keep reading...
Now that we've explained how the tar command works, we can explain how this gets installed.
Every Linux system has something called the
$PATH variable, which determines where executable files are stored. Among these places is
/usr/local/bin. When you extract that binary inside
/usr/local (which I'm confident is what your install instructions say), the NodeJS binary is being written to
/usr/local/bin/node as per how extractions are done. Similarly, all the libraries are being added to the local library folder and everything pretty much just goes where it belongs.
Now, the caveat (and why this is annoying) is that
apt won't see or understand or realize what's going on. You won't be able to update it through
sudo apt upgrade or similar. You'd need to manually go in and clean the old NodeJS install and then put in the new one in case you ever want to upgrade.
I would recommend you just run
sudo apt install nodejs-legacy instead. Less pain, and it automatically updates for you.