<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>n &amp;mdash; Simple Engineering</title>
    <link>https://getsimple.works/tag:n</link>
    <description></description>
    <pubDate>Tue, 28 Apr 2026 16:07:00 +0000</pubDate>
    <item>
      <title>How to install redis</title>
      <link>https://getsimple.works/how-to-install-redis?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install redis key/value data store on development and production servers.&#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link  &#xA;&#xA;Installing redis on Linux &#xA;&#xA;It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:&#xA;&#xA;$ apt-get update # Fetch list of available updates&#xA;$ apt-get upgrade # Upgrades current packages&#xA;$ apt-get dist-upgrade # Installs only new updates&#xA;Example: updating aptitude binaries&#xA;&#xA;At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.&#xA;&#xA;Installing a redis on Linux using apt&#xA;&#xA;Updating   The &#xA;Installing binaries &#xA;$ curl -O http://download.redis.io/redis-stable.tar.gz&#xA;$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable &#xA;$ make &amp;&amp; make install&#xA;Configure redis - for first time installs &#xA;&#xA;Install via PPA &#xA;$ apt-get install -y python-software-properties #provides access to add-apt-repository &#xA;$ apt-get install -y software-properties-common python-software-properties&#xA;&#xA;@link https://packages.ubuntu.com/bionic/redis &#xA;$ add-apt-repository -y ppa:bionic/redis # Alternatively rwky/redis&#xA;$ apt-get update&#xA;$ apt-get install -y redis-server&#xA;&#xA;Starting Redis for development on Mac&#xA;$ redis-server /usr/local/etc/redis.conf &#xA;Example: installing redis binaries with aptitude&#xA;&#xA;Installing redis on a Mac system &#xA; &#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. &#xA;&#xA;$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install/uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a redis on a macOS  using curl&#xA;&#xA;Installing redis via a curl command is not that different as on Linux system. The following instructions can accomplish the installation. &#xA;&#xA;Installing binaries &#xA;$ curl -O http://download.redis.io/redis-stable.tar.gz&#xA;$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable &#xA;$ make &amp;&amp; make install&#xA;Configure redis - for first time installs &#xA;Example: install redis binaries using curl and make&#xA;&#xA;Installing a redis on a Mac using homebrew&#xA;&#xA;$ brew install redis        # Installation following formula@version template &#xA;$ brew services start redis # Starting redis as a service  &#xA;&#xA;Alternatively start as usual &#xA;$ redis-server /usr/local/etc/redis.conf&#xA;Running on port: 6379&#xA;Example: install redis binaries using homebrew&#xA;&#xA;Installing redis on a Windows machine&#xA;&#xA;MacOs comes with Python and Ruby already enabled, these two languages are somehow required to run successfully a nodejs environment. This is an easy target as redis gives windows binaries that we can download and install on a couple of clicks.&#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing a mongodb instance. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is recommended that the only pair minor versions be considered for version upgrades. This is because minor versions, as well as major versions, are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches do not introduce breaking changes. Those can therefore be automated. &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf&#xA;&#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install redis on various platforms. Even though configuration was beyond the scope of this article, we managed to get everyday quick refreshers out. &#xA;&#xA;Reading list &#xA;&#xA;Install and config Redis on Mac OS X via Homebrew&#xA;Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #nvm #n #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install <code>redis</code> key/value data store on development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<h2 id="installing-redis-on-linux" id="installing-redis-on-linux">Installing <code>redis</code> on Linux</h2>

<p>It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:</p>

<pre><code class="language-shell">$ apt-get update # Fetch list of available updates
$ apt-get upgrade # Upgrades current packages
$ apt-get dist-upgrade # Installs only new updates
</code></pre>

<p><em><em>Example</em>: updating aptitude binaries</em></p>

<p>At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.</p>

<h3 id="installing-a-redis-on-linux-using-apt" id="installing-a-redis-on-linux-using-apt">Installing a <code>redis</code> on Linux using <code>apt</code></h3>

<p>Updating <code>redis</code> – In case the above global update didn&#39;t take effect.
  The <code>-y</code> option passes YES, so there are no prompt for <code>Y/N?</code> while installing libraries.</p>

<pre><code class="language-shell"># Installing binaries 
$ curl -O http://download.redis.io/redis-stable.tar.gz
$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable 
$ make &amp;&amp; make install
# Configure redis - for first time installs 

# Install via PPA 
$ apt-get install -y python-software-properties #provides access to add-apt-repository 
$ apt-get install -y software-properties-common python-software-properties

# @link https://packages.ubuntu.com/bionic/redis 
$ add-apt-repository -y ppa:bionic/redis # Alternatively rwky/redis
$ apt-get update
$ apt-get install -y redis-server

# Starting Redis for development on Mac
$ redis-server /usr/local/etc/redis.conf 
</code></pre>

<p><em><em>Example</em>: installing <code>redis</code> binaries with aptitude</em></p>

<h2 id="installing-redis-on-a-mac-system" id="installing-redis-on-a-mac-system">Installing <code>redis</code> on a Mac system</h2>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to install/uninstall things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using homebrew</em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-redis-on-a-macos-using-curl" id="installing-a-redis-on-a-macos-using-curl">Installing a <code>redis</code> on a macOS  using <code>curl</code></h3>

<p>Installing <code>redis</code> via a <code>curl</code> command is not that different as on Linux system. The following instructions can accomplish the installation.</p>

<pre><code class="language-shell"># Installing binaries 
$ curl -O http://download.redis.io/redis-stable.tar.gz
$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable 
$ make &amp;&amp; make install
# Configure redis - for first time installs 
</code></pre>

<p><em><em>Example</em>: install <code>redis</code> binaries using <code>curl</code> and <code>make</code></em></p>

<h3 id="installing-a-redis-on-a-mac-using-homebrew" id="installing-a-redis-on-a-mac-using-homebrew">Installing a <code>redis</code> on a Mac using <code>homebrew</code></h3>

<pre><code class="language-shell">$ brew install redis        # Installation following &lt;formula&gt;@&lt;version&gt; template 
$ brew services start redis # Starting redis as a service  

# Alternatively start as usual 
$ redis-server /usr/local/etc/redis.conf
# Running on port: 6379
</code></pre>

<p><em><em>Example</em>: install <code>redis</code> binaries using <code>homebrew</code></em></p>

<h2 id="installing-redis-on-a-windows-machine" id="installing-redis-on-a-windows-machine">Installing <code>redis</code> on a Windows machine</h2>

<p>MacOs comes with Python and Ruby already enabled, these two languages are somehow required to run successfully a <code>nodejs</code> environment. This is an easy target as <a href="https://redis.io/download"><code>redis</code></a> gives windows binaries that we can download and install on a couple of clicks.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing a <code>mongodb</code> instance. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is recommended that the only pair <strong><em>minor</em></strong> versions be considered for version upgrades. This is because minor versions, as well as major versions, are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches do not introduce breaking changes. Those can therefore be automated.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>redis</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-redis-to-run-with-a-nodejs-server">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="reading-list" id="reading-list">Reading list</h2>
<ul><li><a href="https://medium.com/@petehouston/install-and-config-redis-on-mac-os-x-via-homebrew-eb8df9a4f298">Install and config Redis on Mac OS X via Homebrew</a></li>
<li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:nvm" class="hashtag"><span>#</span><span class="p-category">nvm</span></a> <a href="https://getsimple.works/tag:n" class="hashtag"><span>#</span><span class="p-category">n</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-redis</guid>
      <pubDate>Fri, 31 Jan 2020 22:45:40 +0000</pubDate>
    </item>
    <item>
      <title>How to install nodejs</title>
      <link>https://getsimple.works/how-to-install-nodejs?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install a nodejs environment, on both development and production servers. &#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link  &#xA;&#xA;Installing nodejs on Linux &#xA;&#xA;When running aptitude, or similar package management tools, installing nodejs becomes quite like installing any other program. The following commands are the ones most people tend to use. &#xA;&#xA;Installing a nodejs on Linux using apt&#xA;&#xA;Challenge using this strategy, is to make sure we have nodejs in our PPA database.&#xA;&#xA;Adding and using nodejs from individual PPAs &#xA;$ sudo add-apt-repository ppa:chris-lea/nodejs&#xA;$ sudo apt-get update&#xA;$ sudo apt-get install -y nodejs&#xA;&#xA;Removing Chriss Lea PPA before using NodeSource PPA &#xA;# @link https://github.com/nodesource/distributions#manual-installation&#xA;$ sudo add-apt-repository -y -r ppa:chris-lea/nodejs&#xA;$ sudo rm -f /etc/apt/sources.list.d/chris-lea-nodejs-.list&#xA;$ sudo rm -f /etc/apt/sources.list.d/chris-lea-nodejs-.list.save&#xA;&#xA;Adding and using NodeSource distribution &#xA;@link https://github.com/nodesource/distributions &#xA;$ curl -sL https://deb.nodesource.com/setup10.x | sudo -E bash -&#xA;Alternatively &#xA;$ curl -sL https://deb.nodesource.com/setup | sudo bash -&#xA;$ sudo apt-get install -y nodejs&#xA;Example: install nodejs binaries aptitude&#xA;&#xA;Once we have nodejs to be recognized by aptitude, most operations becomes a little more familiar. Normally running apt-get upgrade should upgrade all binaries including nodejs. We should mention that updating nodejs also updates npm. &#xA;&#xA;Installing a nodejs on Linux using nvm&#xA;&#xA;When we want to test an application against a particular version of nodejs, the environment we work in should be able to manage multiple versions of nodejs. That is where tools such as nvm come into play. &#xA;&#xA;To make the tool work, we will have to have nodejs installed on our work environment. The second step will be to download and install nvm to our work environment. After installation, we can use tools provided by the nvm to install and toggle a specific version. &#xA;&#xA;$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash&#xA;Or &#xA;$ wget https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash&#xA;Install a particular nodejs version&#xA;$ nvm install vMajor.Minor.Patch&#xA;toggle a particular nodejs version&#xA;$ nvm use  vMajor.Minor.Patch&#xA;execture code with a particular nodejs version &#xA;$ nvm run  vMajor.Minor.Patch /path/to/server.js&#xA;uninstall a particular nodejs version&#xA;$ nvm uninstall  vMajor.Minor.Patch&#xA;Example: working with nvm tool&#xA;&#xA;An approach a bit similar to this is available for yet another nodejs version manager known under pseudonym n&#xA;&#xA;Installing nodejs on macOS &#xA;&#xA;It is possible to download and install nodejs manually, with ready to use installer. However, when wanting to tuning nodejs environment at our taste, messing with methods and other tools described below becomes a must. &#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation on macOS a breeze. We should also highlight that homebrew requires xcode to be available on the system. &#xA;&#xA;$ /usr/bin/ruby -e \&#xA;    &#34;$(curl -fsSL https://raw.githubusercontent.com \&#xA;    /Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install and uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a nodejs on a macOS  using curl&#xA;&#xA;nodejs installation guide suggests this alternative for the MacOs. However, we have to customize a download directory, the version, and installation directory. &#xA;&#xA;$ curl &#34;https://nodejs.org/dist/latest/node-${VERSION:-$(wget \&#xA;    -qO- https://nodejs.org/dist/latest/ | \&#xA;    sed -nE &#39;s|.  node-(.)\.pkg/a.|\1|p&#39;)}.pkg&#34;   \&#xA;    &#34;$HOME/Downloads/node-latest.pkg&#34; &amp;&amp; sudo installer \&#xA;    -store -pkg &#34;$HOME/Downloads/node-latest.pkg&#34; -target \&#xA;    &#34;/&#34;&#xA;Example: installation instruction as provided by nodejs&#xA;&#xA;Using homebrew, as demo-ed in next paragraph, may be the most popular approach to install nodejs version on a macOS  machine. &#xA;&#xA;Installing a nodejs on a Mac using homebrew&#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. &#xA;&#xA;$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;In case the homebrew is already available, it is a good practice to update it before adding new software. In the next code sample, we install some tools such as wget, sometimes useful to download binaries.&#xA;&#xA;how to install things with brew &#xA;&#xA;$ brew install nodejs  &#xA;Example: install nodejs binaries using homebrew&#xA;&#xA;After installation, add binary to the PATH [ /usr/local/share/npm/bin ],  $ nano /etc/paths, append the path /usr/local/share/npm/bin at the end of the file. &#xA;&#xA;  homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;Installing nodejs on a Windows machine&#xA;&#xA;MacOs and most Linux distributions come with Python and Ruby already enabled. These two languages are somehow required to run successfully a nodejs environment on any server. This is an easy target as nodejs gives windows binaries that we can download and install on a couple of clicks.&#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing a nodejs instance. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is not recommended to consider minor/major versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.  &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf_&#xA; &#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install nodejs on various platforms. Even though configuration was beyond the scope of this article*, we managed to get everyday quick refreshers out. &#xA;&#xA;Reading list &#xA;&#xA;Manual Installation ~ NodeSource&#xA;Distributions ~ NodeSource&#xA;Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #nvm #n #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install a <code>nodejs</code> environment, on both development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<h2 id="installing-nodejs-on-linux" id="installing-nodejs-on-linux">Installing <code>nodejs</code> on Linux</h2>

<p>When running aptitude, or similar package management tools, installing <code>nodejs</code> becomes quite like installing any other program. The following commands are the ones most people tend to use.</p>

<h3 id="installing-a-nodejs-on-linux-using-apt" id="installing-a-nodejs-on-linux-using-apt">Installing a <code>nodejs</code> on Linux using <code>apt</code></h3>

<p>Challenge using this strategy, is to make sure we have <code>nodejs</code> in our PPA database.</p>

<pre><code class="language-shell"># Adding and using nodejs from individual PPAs 
$ sudo add-apt-repository ppa:chris-lea/nodejs
$ sudo apt-get update
$ sudo apt-get install -y nodejs


# Removing Chriss Lea PPA before using NodeSource PPA 
# @link https://github.com/nodesource/distributions#manual-installation
$ sudo add-apt-repository -y -r ppa:chris-lea/nodejs
$ sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
$ sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save


# Adding and using NodeSource distribution 
# @link https://github.com/nodesource/distributions 
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
# Alternatively 
$ curl -sL https://deb.nodesource.com/setup | sudo bash -
$ sudo apt-get install -y nodejs
</code></pre>

<p><em><em>Example</em>: install <code>nodejs</code> binaries aptitude</em></p>

<p>Once we have <code>nodejs</code> to be recognized by aptitude, most operations becomes a little more familiar. Normally running <code>apt-get upgrade</code> should upgrade all binaries including <code>nodejs</code>. We should mention that updating <code>nodejs</code> also updates <code>npm</code>.</p>

<h3 id="installing-a-nodejs-on-linux-using-nvm" id="installing-a-nodejs-on-linux-using-nvm">Installing a <code>nodejs</code> on Linux using <code>nvm</code></h3>

<p>When we want to test an application against a particular version of <code>nodejs</code>, the environment we work in should be able to manage multiple versions of <code>nodejs</code>. That is where tools such as nvm come into play.</p>

<p>To make the tool work, we will have to have <code>nodejs</code> installed on our work environment. The second step will be to download and install <code>nvm</code> to our work environment. After installation, we can use tools provided by the nvm to install and toggle a specific version.</p>

<pre><code class="language-shell">$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# Or 
$ wget https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# Install a particular nodejs version
$ nvm install v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt;
# toggle a particular nodejs version
$ nvm use  v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt;
# execture code with a particular nodejs version 
$ nvm run  v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt; /path/to/server.js
# uninstall a particular nodejs version
$ nvm uninstall  v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt;
</code></pre>

<p><em><em>Example:</em> working with <a href="https://github.com/nvm-sh/nvm"><code>nvm</code></a> tool</em></p>

<p>An approach a bit similar to this is available for yet another <code>nodejs</code> version manager known under pseudonym <a href="https://www.npmjs.com/package/n"><code>n</code></a></p>

<h2 id="installing-nodejs-on-macos" id="installing-nodejs-on-macos">Installing <code>nodejs</code> on macOS</h2>

<p>It is possible to download and install <code>nodejs</code> manually, with ready to use installer. However, when wanting to tuning <code>nodejs</code> environment at our taste, messing with methods and other tools described below becomes a must.</p>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on <code>ruby</code> runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation on macOS a breeze. We should also highlight that <code>homebrew</code> requires <code>xcode</code> to be available on the system.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e \
    &#34;$(curl -fsSL https://raw.githubusercontent.com \
    /Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to <strong><em>install</em></strong> and <strong><em>uninstall</em></strong> things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using homebrew</em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-nodejs-on-a-macos-using-curl" id="installing-a-nodejs-on-a-macos-using-curl">Installing a <code>nodejs</code> on a macOS  using <code>curl</code></h3>

<p><code>nodejs</code> installation guide suggests this alternative for the MacOs. However, we have to customize a download directory, the version, and installation directory.</p>

<pre><code class="language-shell">$ curl &#34;https://nodejs.org/dist/latest/node-${VERSION:-$(wget \
    -qO- https://nodejs.org/dist/latest/ | \
    sed -nE &#39;s|.*&gt;node-(.*)\.pkg&lt;/a&gt;.*|\1|p&#39;)}.pkg&#34; &gt; \
    &#34;$HOME/Downloads/node-latest.pkg&#34; &amp;&amp; sudo installer \
    -store -pkg &#34;$HOME/Downloads/node-latest.pkg&#34; -target \
    &#34;/&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://nodejs.org/en/download/package-manager/"><code>nodejs</code></a></em></p>

<p>Using <code>homebrew</code>, as demo-ed in next paragraph, may be the most popular approach to install <code>nodejs</code> version on a macOS  machine.</p>

<h3 id="installing-a-nodejs-on-a-mac-using-homebrew" id="installing-a-nodejs-on-a-mac-using-homebrew">Installing a <code>nodejs</code> on a Mac using <code>homebrew</code></h3>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>In case the <code>homebrew</code> is already available, it is a good practice to update it before adding new software. In the next code sample, we install some tools such as <code>wget</code>, sometimes useful to download binaries.</p>

<p>how to install things with brew</p>

<pre><code class="language-shell">$ brew install nodejs  
</code></pre>

<p><em><em>Example</em>: install <code>nodejs</code> binaries using <code>homebrew</code></em></p>

<p>After installation, add binary to the PATH [ <code>/usr/local/share/npm/bin</code> ],  <code>$ nano /etc/paths</code>, append the path <code>/usr/local/share/npm/bin</code> at the end of the file.</p>

<blockquote><p><code>homebrew</code> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<h2 id="installing-nodejs-on-a-windows-machine" id="installing-nodejs-on-a-windows-machine">Installing <code>nodejs</code> on a Windows machine</h2>

<p>MacOs and most Linux distributions come with Python and Ruby already enabled. These two languages are somehow required to run successfully a <code>nodejs</code> environment on any server. This is an easy target as <a href="https://nodejs.org/en/download/"><code>nodejs</code></a> gives windows binaries that we can download and install on a couple of clicks.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing a <code>nodejs</code> instance. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is not recommended to consider <strong><em>minor</em></strong>/<strong><em>major</em></strong> versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>nodejs</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-redis-to-run-with-a-nodejs-server">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="reading-list" id="reading-list">Reading list</h2>
<ul><li><a href="https://github.com/nodesource/distributions#manual-installation">Manual Installation ~ NodeSource</a></li>
<li><a href="https://github.com/nodesource/distributions">Distributions ~ NodeSource</a></li>
<li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:nvm" class="hashtag"><span>#</span><span class="p-category">nvm</span></a> <a href="https://getsimple.works/tag:n" class="hashtag"><span>#</span><span class="p-category">n</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-nodejs</guid>
      <pubDate>Fri, 31 Jan 2020 22:03:49 +0000</pubDate>
    </item>
  </channel>
</rss>