Installing nodejs and npm on linux
<p>I have having a bit of an issue with installing nodejs and npm on my linux server (which is a pi running raspbian). I had everything set up and running using </p>

<pre><code>sudo apt-get install nodejs npm
</code></pre>

<p>All was fine and dandy, until I found out that apparently these versions are now old. So I removed them</p>

<pre><code>sudo apt-get purge nodejs npm
</code></pre>

<p>Then I found the following answer (<a href="https://stackoverflow.com/questions/12913141/message-failed-to-fetch-from-registry-while-trying-to-install-any-module">here</a>) on SO and ran </p>

<pre><code>curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
</code></pre>

<p>Running node -v have me version 0.6.19...which I'm assuming translates to version 6.19 as opposed to version 0. However, running npm -v told me that it was not installed. So I once again purged nodejs, and looked for another solution. At which point I decided to follow the stuff on nodejs's site (<a href="https://nodejs.org/en/download/package-manager/" rel="noreferrer">here</a>). And I ran the following commands.</p>

<pre><code>curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
</code></pre>

<p>and </p>

<pre><code>sudo apt-get install -y build-essential
</code></pre>

<p>2 issues:</p>

<p>1) The version installed was still 0.6.19. I would rather have version 4.x, since that's what I'm running on my dev machine (macOS Sierra). </p>

<p>2) I still don't have npm. Which renders nodejs useless</p>

<p>Any help on either (but preferably 2) would be great. Thanks in advance.</p>