<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>reecoverasble.github.io</title>
    <description>reecoverasble.github.io</description>
    <link>https://reecoverasble.github.io</link>
    
      
        <item>
          <title></title>
          <description>&lt;blockquote&gt;
  &lt;p&gt;Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;1-sign-up-for-digital-ocean&quot;&gt;1. Sign up for Digital Ocean&lt;/h2&gt;
&lt;p&gt;If you use the referal link below, you get $10 free (1 or 2 months)
https://m.do.co/c/5424d440c63a&lt;/p&gt;

&lt;h2 id=&quot;2-create-a-droplet-and-log-in-via-ssh&quot;&gt;2. Create a droplet and log in via ssh&lt;/h2&gt;
&lt;p&gt;I will be using the root user, but would suggest creating a new user&lt;/p&gt;

&lt;h2 id=&quot;3-install-nodenpm&quot;&gt;3. Install Node/NPM&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

sudo apt install nodejs

node --version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;4-clone-your-project-from-github&quot;&gt;4. Clone your project from Github&lt;/h2&gt;
&lt;p&gt;There are a few ways to get your files on to the server, I would suggest using Git&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone yourproject.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;5-install-dependencies-and-test-app&quot;&gt;5. Install dependencies and test app&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd yourproject
npm install
npm start (or whatever your start command)
# stop app
ctrl+C
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;6-setup-pm2-process-manager-to-keep-your-app-running&quot;&gt;6. Setup PM2 process manager to keep your app running&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo npm i pm2 -g
pm2 start app (or whatever your file name)

# Other pm2 commands
pm2 show app
pm2 status
pm2 restart app
pm2 stop app
pm2 logs (Show log stream)
pm2 flush (Clear logs)

# To make sure app starts when reboot
pm2 startup ubuntu
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;you-should-now-be-able-to-access-your-app-using-your-ip-and-port-now-we-want-to-setup-a-firewall-blocking-that-port-and-setup-nginx-as-a-reverse-proxy-so-we-can-access-it-directly-using-port-80-http&quot;&gt;You should now be able to access your app using your IP and port. Now we want to setup a firewall blocking that port and setup NGINX as a reverse proxy so we can access it directly using port 80 (http)&lt;/h3&gt;

&lt;h2 id=&quot;7-setup-ufw-firewall&quot;&gt;7. Setup ufw firewall&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo ufw enable
sudo ufw status
sudo ufw allow ssh (Port 22)
sudo ufw allow http (Port 80)
sudo ufw allow https (Port 443)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;8-install-nginx-and-configure&quot;&gt;8. Install NGINX and configure&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt install nginx

sudo nano /etc/nginx/sites-available/default
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Add the following to the location part of the server block&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    server_name yourdomain.com www.yourdomain.com;

    location / {
        proxy_pass http://localhost:5000; #whatever port your app runs on
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Check NGINX config
sudo nginx -t

# Restart NGINX
sudo service nginx restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;you-should-now-be-able-to-visit-your-ip-with-no-port-port-80-and-see-your-app-now-lets-add-a-domain&quot;&gt;You should now be able to visit your IP with no port (port 80) and see your app. Now let’s add a domain&lt;/h3&gt;

&lt;h2 id=&quot;9-add-domain-in-digital-ocean&quot;&gt;9. Add domain in Digital Ocean&lt;/h2&gt;
&lt;p&gt;In Digital Ocean, go to networking and add a domain&lt;/p&gt;

&lt;p&gt;Add an A record for @ and for www to your droplet&lt;/p&gt;

&lt;h2 id=&quot;register-andor-setup-domain-from-registrar&quot;&gt;Register and/or setup domain from registrar&lt;/h2&gt;
&lt;p&gt;I prefer Namecheap for domains. Please use this affiliate link if you are going to use them
https://namecheap.pxf.io/c/1299552/386170/5618&lt;/p&gt;

&lt;p&gt;Choose “Custom nameservers” and add these 3&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;ns1.digitalocean.com&lt;/li&gt;
  &lt;li&gt;ns2.digitalocean.com&lt;/li&gt;
  &lt;li&gt;ns3.digitalocean.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It may take a bit to propogate&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Add SSL with LetsEncrypt
```
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
sudo certbot –nginx -d yourdomain.com -d www.yourdomain.com&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;only-valid-for-90-days-test-the-renewal-process-with&quot;&gt;Only valid for 90 days, test the renewal process with&lt;/h1&gt;
&lt;p&gt;certbot renew –dry-run
```&lt;/p&gt;

&lt;p&gt;Now visit https://yourdomain.com and you should see your Node app&lt;/p&gt;
</description>
          <pubDate>2024-05-09T21:45:11+08:00</pubDate>
          <link>https://reecoverasble.github.io/2024-01-07-Quick-Tip-Configuring-NGINX-and-SSL-with-Node.js</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/2024-01-07-Quick-Tip-Configuring-NGINX-and-SSL-with-Node.js</guid>
        </item>
      
    
      
        <item>
          <title></title>
          <description>&lt;h1 id=&quot;installing-node-in-5-minutes-the-final-guide&quot;&gt;Installing Node in 5 minutes: The Final Guide.&lt;/h1&gt;

&lt;p&gt;&lt;del&gt;If you have a shitty internet, it may take a little longer.&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;First, access &lt;a href=&quot;https://nodejs.org/&quot;&gt;Node.js website&lt;/a&gt; and click the big green “Download” button.&lt;/p&gt;

&lt;p&gt;Download finished? Now run the installation. While the installation goes by, grab yourself a coffee or drink some water, then get back at your chair. By now you should have Node.js and NPM (Node’s package manager) installed.&lt;/p&gt;

&lt;p&gt;Now, lets install &lt;a href=&quot;https://github.com/tj/n&quot;&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; to manage (and update) Node versions in seconds on your machine. How to install it? Simply run:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install -g n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;(if you get errors, you probably need administration permissions, try using sudo or equivalent in your OS).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Easy, right? Now, to update your Node.js version, all you have to do is run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n latest&lt;/code&gt;. And you will have the latest Node.js installed and ready to use in your machine.&lt;/p&gt;

&lt;p&gt;To choose which Node.js version you want to use at a given time, run: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt; and choose between the installed versions.&lt;/p&gt;

&lt;h3 id=&quot;so-lets-recap&quot;&gt;So, lets recap:&lt;/h3&gt;

&lt;p&gt;You’ve installed Node.js via their website for the first time. Then you installed the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt; package, which lets you have multiple Node versions in the same machine, doing version updates with one line command.&lt;/p&gt;

&lt;p&gt;Here is what you’ve just installed at the end of this tutorial:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Node.js:&lt;/strong&gt; The V8 JavaScript Engine which will run your JavaScript code locally. Think of it as a JVM (Java).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NPM:&lt;/strong&gt; Node (JavaScript) package manager. You can think of it as a Maven (Java), Composer (PHP) or Gems (Ruby), but for Node.js.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Updating Node to future versions:&lt;/strong&gt; Simply run: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n latest&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Switching between installed Node versions:&lt;/strong&gt; Run: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt;, then select (with arrow keys) which version you want to use. You can check your current node version by running: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node -v&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And thats it. Now you’ve got a minimal environment ready to kick some a*$!&lt;/p&gt;
</description>
          <pubDate>2024-05-09T21:45:11+08:00</pubDate>
          <link>https://reecoverasble.github.io/2024-01-06-Installing-Node-in-5-minutes-The-Final-Guide</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/2024-01-06-Installing-Node-in-5-minutes-The-Final-Guide</guid>
        </item>
      
    
      
        <item>
          <title>How to Setup Windows as a Node.js Server Environment</title>
          <description>&lt;p&gt;Install the following in this order:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;a href=&quot;https://github.com/cmderdev/cmder#installation&quot;&gt;cmder&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;Console Emulator for Windows. Use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Download Full&lt;/code&gt; link.&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;ul&gt;
      &lt;li&gt;Download and unzip into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Users\your-username-here\cmder&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;Open the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Users\your-username-here\cmder&lt;/code&gt; directory right click on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cmdre.exe&lt;/code&gt; click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pin to Taskbar&lt;/code&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;a href=&quot;https://github.com/coreybutler/nvm-windows#installation--upgrades&quot;&gt;nvm-windows&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;Node Version Manager for Windows.&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;ul&gt;
      &lt;li&gt;Download &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm-setup.zip&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;Extract the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm-setup.exe&lt;/code&gt; file somewhere and run it.&lt;/li&gt;
      &lt;li&gt;TODO: The installer isn’t updating the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt; correctly so the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt; commands may not work. Make sure to add the following to Window’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt;:
        &lt;ul&gt;
          &lt;li&gt;Open the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cmder&lt;/code&gt; console you installed above and run:
            &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  setx path &quot;%path%;C:\Users\your-username-here\AppData\Roaming\nvm;C:\Program Files\nodejs;&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;            &lt;/div&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;run:&lt;/p&gt;

        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  nvm install 8.9.4
  nvm use 8.9.4
  node -v
  # Should return 8.9.4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;a href=&quot;https://github.com/felixrieseberg/windows-build-tools&quot;&gt;windows-build-tools&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;C++ Build Tools for Windows using npm&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &amp;gt; Note: This will take 10 - 30 minutes to complete.  * Right click on the `cmder` console icon you installed above and run it as an Administrator. Then run:    * `npm install --global --production windows-build-tools`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You should now have the commands, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; available from any command line or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cmder&lt;/code&gt; console.&lt;/p&gt;
</description>
          <pubDate>2024-01-12T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/windows-local-nodejs-server</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/windows-local-nodejs-server</guid>
        </item>
      
    
      
        <item>
          <title>Setup a Node.js project with Typescript, ESLint, Prettier, Husky</title>
          <description>&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/11991333/72227393-f67be200-3593-11ea-8510-7bec5d98afc6.jpeg&quot; alt=&quot;1_D8Wwwce8wS3auLAiM3BQKA&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Starting a personal node project could be easy; starting a team node project could be challenging.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I am a developer currently working in SEEK Australia.&lt;/p&gt;

&lt;p&gt;In my experience, common mistakes developer make when starting a projects are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;No Linting&lt;/li&gt;
  &lt;li&gt;Lack of compile-time type checking (not really mistake but less desirable in my preference)&lt;/li&gt;
  &lt;li&gt;Inconsistent code styling&lt;/li&gt;
  &lt;li&gt;Linter breaking the build&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, I am going to not only to share how to address these above problems, but also some of the best practices we implement in our team at SEEK.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The article assumes the reader knows the basics about nodes and typescripts&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;typescript&quot;&gt;Typescript&lt;/h2&gt;

&lt;p&gt;We can start off by a simple node project consisting only the package.json file&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn add typescript &lt;span class=&quot;nt&quot;&gt;--dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After adding the dev dependency, create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ts.config.json&lt;/code&gt; file under the root of the node project&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;compilerOptions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;target&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;es2018&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;module&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;commonjs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;outDir&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dist&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sourceMap&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;include&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;src/**/*.ts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;exclude&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;node_modules&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The above are the minimal settings of typescript compiler &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tsc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It tells the compiler to&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;es2018&lt;/code&gt; syntax when generating the distributable&lt;/li&gt;
  &lt;li&gt;use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commonjs&lt;/code&gt; module format.&lt;/li&gt;
  &lt;li&gt;generate *.js to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dist&lt;/code&gt; folder&lt;/li&gt;
  &lt;li&gt;generate source map&lt;/li&gt;
  &lt;li&gt;include all *.ts file inside &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/src&lt;/code&gt; folder&lt;/li&gt;
  &lt;li&gt;exclude all files inside &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/node_modules&lt;/code&gt; folder&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Fancy configuration of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ts.config.json&lt;/code&gt; is beyond the scope of this article&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Adding the following line to package.json&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tsc&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To build, run the following in shell&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;eslint&quot;&gt;ESLint&lt;/h2&gt;

&lt;p&gt;We have a handful choices of linting tools for node development, but the de-factor standard these days for typescript is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ESLint&lt;/code&gt;. Partnering with prettier it really improves consistency and productivity of a development team.&lt;/p&gt;

&lt;p&gt;Again we are starting off by adding the dev dependencies&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn add eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser &lt;span class=&quot;nt&quot;&gt;--dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ESLint does not support typescript out of the box. Fortunately we are able to add the typescript support by these two packages &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@typescript-eslint/eslint-plugin&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@typescript-eslint/parser&lt;/code&gt; thanks to the ESLint team’s modular design.&lt;/p&gt;

&lt;p&gt;The next thing is to create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.eslintrc&lt;/code&gt; file. It does not have a file extension but the default is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JSON&lt;/code&gt; format:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;parser&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;@typescript-eslint/parser&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;extends&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;plugin:@typescript-eslint/recommended&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;parserOptions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;ecmaVersion&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2018&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sourceType&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;module&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;rules&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It tells the ESLint linter to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;use Typescript parser&lt;/li&gt;
  &lt;li&gt;use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Recommended Typescript preset&lt;/code&gt; for linting&lt;/li&gt;
  &lt;li&gt;use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ES2018&lt;/code&gt; and  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module&lt;/code&gt; sourceType to match ts.config settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Add the following lines in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;lint&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eslint src/**/*.ts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;format&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eslint src/**/*.ts --fix&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To lint, run the following in shell&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn lint
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To format the code to comply with linting rules, run the following in shell&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn format
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;prettier&quot;&gt;Prettier&lt;/h2&gt;

&lt;p&gt;Prettier drastically improves team consistency by automatically formatting the code. To enable prettier, we first install it by running:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn add prettier &lt;span class=&quot;nt&quot;&gt;--dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Configure prettier by adding a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.prettierrc&lt;/code&gt; to the root of the project with the following content&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;semi&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;trailingComma&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;all&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;singleQuote&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;printWidth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;120&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;tabWidth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The setting let Prettier to&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ensure semi colon at the end of each statement&lt;/li&gt;
  &lt;li&gt;Ensure trailing comma at the end of each statement&lt;/li&gt;
  &lt;li&gt;Convert all double quotes to single quotes where applicable&lt;/li&gt;
  &lt;li&gt;Break into new lines for all lines greater than 120 characters wide&lt;/li&gt;
  &lt;li&gt;Ensure tab width is 2 characters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Visual Studio Code, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl (CMD) + P&lt;/code&gt; then select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Format Code&lt;/code&gt;, or enable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Format on Save&lt;/code&gt; in settings for best result.&lt;/p&gt;

&lt;h2 id=&quot;husky&quot;&gt;Husky&lt;/h2&gt;

&lt;p&gt;No matter how careful I am, I always endup with situations where I changed and committed the code to Github without linting, and that can lead to failure CI builds.&lt;/p&gt;

&lt;p&gt;A good pratcice is to lint before commit. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Husky&lt;/code&gt; is a very popular plugin to achieve so.&lt;/p&gt;

&lt;p&gt;Install Husky by&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yarn add husky --save-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Husky does not have its own configuration files. Instead we will add its config into package.json:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;husky&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;hooks&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;pre-commit&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;yarn lint&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next time you commit, husky would exit the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git commit&lt;/code&gt; when the code does not pass linting.&lt;/p&gt;

&lt;h2 id=&quot;the-end&quot;&gt;The End&lt;/h2&gt;

&lt;p&gt;There are so many more things you could do to your project to ensure productivity, consistency and coding styles, but I think this is a good start. This article will be subject to improvements to the latest changes and practices.&lt;/p&gt;

&lt;p&gt;If you find this article useful please let me know.&lt;/p&gt;

</description>
          <pubDate>2024-01-11T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/Setup-a-Nodejs-project-with-Typescript-ESLint-Prettier-Husky</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/Setup-a-Nodejs-project-with-Typescript-ESLint-Prettier-Husky</guid>
        </item>
      
    
      
        <item>
          <title>How to deploy a simple Node.js+MongoDB app</title>
          <description>&lt;h3 id=&quot;clone-a-nodejs-application-from-github&quot;&gt;Clone a Node.js application from GitHub&lt;/h3&gt;

&lt;p&gt;First, clone from the following URL to Ubuntu VM:&lt;/p&gt;

&lt;p&gt;https://github.com/potikanond/docker-node-sample3.git&lt;/p&gt;

&lt;p&gt;On Ubuntu VM run the following command:&lt;/p&gt;

&lt;p&gt;`
$ git clone https://github.com/potikanond/docker-node-sample3.git
`&lt;/p&gt;

&lt;p&gt;This will clone the application from GitHub to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker-node-sample3&lt;/code&gt; directory.&lt;/p&gt;

&lt;h3 id=&quot;review-the-nodejs-application&quot;&gt;Review the Node.js application&lt;/h3&gt;

&lt;p&gt;package.json:&lt;/p&gt;
&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;docker-node-mongo&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1.0.0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;main&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;index.js&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;node index.js&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;keywords&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;license&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;dependencies&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;body-parser&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;^1.18.3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;ejs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;^2.6.1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;express&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;^4.16.3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;mongoose&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;^5.2.7&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Dependencies:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;express&lt;/em&gt; : a Node.js framework for web application (and api) development.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;ejs&lt;/em&gt; : Embedded JavaScript template is one of a Node.js template engines for generate HTML using JavaScript.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;body-parser&lt;/em&gt; : a middleware for Node.js, used to parse incoming web request, help extracting passing parameters.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;mongoose&lt;/em&gt; : a library for Node.js to work with MongoDB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;start-the-nodejs-application-right-way&quot;&gt;Start the Node.js application right way?&lt;/h3&gt;

&lt;p&gt;The answer is &lt;strong&gt;NOT&lt;/strong&gt; at this step. &lt;strong&gt;This application stores and retrieves data on MongoDB, therefore, we need to configure MongoDB first.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But if you really want to start the Node.js application, we need to install &lt;strong&gt;Node.js&lt;/strong&gt; on the Ubuntu VM. After that, go into the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker-node-sample3&lt;/code&gt; directory and enter the following command:&lt;/p&gt;

&lt;p&gt;`
$ npm start
`&lt;/p&gt;

&lt;p&gt;If we do not have MongoDB then this would give us an &lt;strong&gt;ERROR&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;
$ npm start

&amp;gt; docker-node-mongo@1.0.0 start /Users/dpotikan/workspace/tutorial-docker/docker-node-sample3
&amp;gt; node index.js

Server running...
{ MongoNetworkError: failed to connect to server [mongo:27017] on first connect 
  [MongoNetworkError: getaddrinfo ENOTFOUND mongo mongo:27017] ... }
&lt;/pre&gt;

&lt;p&gt;With Docker, we will NOT install Node.js on the docker host but we will create a Node.js container and run the application inside.&lt;/p&gt;

&lt;h3 id=&quot;create-a-docker-image-for-the-nodejs-application&quot;&gt;Create a docker image for the Node.js application&lt;/h3&gt;

&lt;p&gt;First, create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt; inside the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker-node-sample3&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Dockerfile:&lt;/p&gt;
&lt;pre&gt;
FROM node:10-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD [&quot;npm&quot;, &quot;start&quot;]
&lt;/pre&gt;

&lt;p&gt;For more detail on &lt;strong&gt;dockerizing a Node.js web app&lt;/strong&gt;, see the following link:
https://nodejs.org/en/docs/guides/nodejs-docker-webapp/&lt;/p&gt;

&lt;h3 id=&quot;create-dockerignore-file-in-the-same-directory-as-the-dockerfile&quot;&gt;Create &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.dockerignore&lt;/code&gt; file in the same directory as the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;.dockerignore:&lt;/p&gt;
&lt;pre&gt;
node_modules
npm-debug.log
&lt;/pre&gt;

&lt;p&gt;This will prevent &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;local_modules&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;debug logs&lt;/code&gt; from being copied onto your Docker image and overwriting modules installed within your image.&lt;/p&gt;

&lt;h3 id=&quot;building-your-nodejs-docker-image&quot;&gt;Building your Node.js docker image&lt;/h3&gt;

&lt;p&gt;Use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker image build ... &lt;/code&gt; command to build and tag image.&lt;/p&gt;

&lt;pre&gt;
$ docker image build -t cpe405/example33 .
Sending build context to Docker daemon  148.5kB
Step 1/7 : FROM node:10-alpine
 ---&amp;gt; 4e50ad7c0e0b
Step 2/7 : WORKDIR /usr/src/app
 ---&amp;gt; Running in 5103a44253d3
Removing intermediate container 5103a44253d3
 ---&amp;gt; 792d79e04737
Step 3/7 : COPY package*.json ./
 ---&amp;gt; b2e4d3253e7f
Step 4/7 : RUN npm install
 ---&amp;gt; Running in 5c75c3eb9927
npm WARN docker-node-mongo@1.0.0 No description
npm WARN docker-node-mongo@1.0.0 No repository field.

added 80 packages from 62 contributors and audited 181 packages in 6.483s
found 0 vulnerabilities

Removing intermediate container 5c75c3eb9927
 ---&amp;gt; 0bd134e0855a
Step 5/7 : COPY . .
 ---&amp;gt; da43997f294f
Step 6/7 : EXPOSE 3000
 ---&amp;gt; Running in 7467dab066a3
Removing intermediate container 7467dab066a3
 ---&amp;gt; 23348db6b2bc
Step 7/7 : CMD [ &quot;npm&quot;, &quot;start&quot; ]
 ---&amp;gt; Running in 15a2309daf6f
Removing intermediate container 15a2309daf6f
 ---&amp;gt; 5e97c2c283d5
Successfully built 5e97c2c283d5
Successfully tagged cpe405/example33:latest
&lt;/pre&gt;

&lt;p&gt;If we would create and start a container from this image without MongoDB, there would be &lt;strong&gt;ERROR&lt;/strong&gt; as shown before.&lt;/p&gt;

&lt;pre&gt;
$ docker container run -p 8080:3000 cpe405/example33

&amp;gt; docker-node-mongo@1.0.0 start /usr/src/app
&amp;gt; node index.js

Server running...
{ MongoNetworkError: failed to connect to server [mongo:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongo mongo:27017] ... }
&lt;/pre&gt;

&lt;h3 id=&quot;start-the-application-properly&quot;&gt;Start the application properly&lt;/h3&gt;

&lt;p&gt;To start the application properly. First, start the MongoDB container:&lt;/p&gt;

&lt;p&gt;`
$ docker container run -d –name my_mongo -p 27017:27017 mongo:4.0.1-xenial
`&lt;/p&gt;

&lt;p&gt;We will use the mongo container’s name, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;my_mongo&lt;/code&gt;, for linking with the Node.js container.
Next, start the Node.js container (in foreground) and &lt;strong&gt;link&lt;/strong&gt; to the MongoDB container.&lt;/p&gt;

&lt;pre&gt;
$ docker container run -p 8080:3000 --link my_mongo:mongo cpe405/example33

&amp;gt; docker-node-mongo@1.0.0 start /usr/src/app
&amp;gt; node index.js

Server running...
MongoDB Connected
&lt;/pre&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--link my_mongo:mongo&lt;/code&gt; option tells docker to map the MongoDB container’s name, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;my_mongo&lt;/code&gt;, as the name &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mongo&lt;/code&gt; for the Node.js container. If we take a look in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.js&lt;/code&gt; file, we will see that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mongoose&lt;/code&gt; use the name &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mongo&lt;/code&gt; to refer to MongoDB container.&lt;/p&gt;

&lt;p&gt;index.js:&lt;/p&gt;
&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;mongoose&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;mongodb://mongo:27017/docker-node-mongo&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;useNewUrlParser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;MongoDB Connected&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, we can access the Node.js app by &lt;em&gt;http://localhost:8080&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;
&lt;p&gt;To deploy the Node.js app, we need to manually start a MongoDB container first then the Node.js app container.
Next we will learn how to use &lt;strong&gt;docker-compose&lt;/strong&gt; tool to deploy the app.&lt;/p&gt;
</description>
          <pubDate>2024-01-10T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/How-to-deploy-a-simple-Node-MongoDB-app</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/How-to-deploy-a-simple-Node-MongoDB-app</guid>
        </item>
      
    
      
        <item>
          <title>Portable Node.js and NPM on windows</title>
          <description>&lt;ol&gt;
  &lt;li&gt;Get node binary (node.exe) from http://nodejs.org/download/&lt;/li&gt;
  &lt;li&gt;Create the folder where node will reside and move node.exe to it&lt;/li&gt;
  &lt;li&gt;Download the last zip version of npm from http://nodejs.org/dist/npm&lt;/li&gt;
  &lt;li&gt;Unpack the zip inside the node folder&lt;/li&gt;
  &lt;li&gt;Download the last tgz version of npm from http://nodejs.org/dist/npm&lt;/li&gt;
  &lt;li&gt;Open the tgz file and unpack only the file &lt;strong&gt;bin/npm&lt;/strong&gt; (without extension) directly on the node folder.&lt;/li&gt;
  &lt;li&gt;Add the the node folder and the packages/bin folder to PATH&lt;/li&gt;
  &lt;li&gt;On a command prompt execute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm install -g npm&lt;/code&gt; to update npm to the latest version&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now you can use npm and node from windows cmd or from bash shell like Git Bash of msysgit.&lt;/p&gt;
</description>
          <pubDate>2024-01-09T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/Portable-20Node.js-20andNPM-20on-20windows</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/Portable-20Node.js-20andNPM-20on-20windows</guid>
        </item>
      
    
      
        <item>
          <title>Node + MongoDB Server Setup Ubuntu 22.04 LTS</title>
          <description>&lt;p&gt;How to setup a Node.js + MongoDB environment with PM2 and Let’s Encrypt&lt;/p&gt;

&lt;h4 id=&quot;login-to-your-server-as-root&quot;&gt;Login to your server as root&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh root@your_server_ip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;update-the-system-before-doing-anything&quot;&gt;Update the system before doing anything&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get update
sudo apt-get upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;create-a-non-root-user-and-give-it-sudo-permissions&quot;&gt;Create a non-root user and give it sudo permissions&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* adduser braitsch
* usermod -aG sudo braitsch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;copy-ssh-key-over-to-the-non-root-user-home-directory&quot;&gt;Copy ssh key over to the non-root user home directory&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rsync --archive --chown=braitsch:braitsch ~/.ssh /home/braitsch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;attempt-to-login-as-braitsch-if-successful-close-root-session&quot;&gt;Attempt to login as braitsch, if successful close root session&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh braitsch@your_server_ip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install-nodejs-via-nvm&quot;&gt;Install Node.js via nvm&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;check-installation-succeeded--install-the-latest-lts-version&quot;&gt;Check installation succeeded &amp;amp; install the latest lts version&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nvm list-remote
nvm install --lts
node -v
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install-mongodb-v60&quot;&gt;&lt;a href=&quot;https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/&quot;&gt;Install MongoDB v6.0&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
echo &quot;deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse&quot; | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;start-mongodb-as-a-service--confirm-that-its-running&quot;&gt;Start MongoDB as a service &amp;amp; confirm that it’s running&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo systemctl start mongod
sudo systemctl status mongod
sudo systemctl enable mongod
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install--configure-nginx&quot;&gt;&lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-22-04#step-5-%E2%80%93-setting-up-server-blocks-(recommended)&quot;&gt;Install &amp;amp; Configure NGINX&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt update
sudo apt install nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;setup-nginx-server-block&quot;&gt;Setup NGINX Server Block&lt;/h4&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo nano /etc/nginx/sites-available/my_domain&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;server {

	server_name my_domain.org www.my_domain.org;
	root /home/braitsch/site/server; # required to serve static images

	location / {
		proxy_pass http://localhost:8081; #nuxt app
		proxy_http_version 1.1;
		proxy_set_header Host $host;
	}

	location /api {
		proxy_pass http://localhost:8080; #express app
		proxy_http_version 1.1;
		proxy_set_header Host $host;
		client_body_buffer_size 1M; #required for image uploads
		client_max_body_size 100M; #required for image uploads
	}

	location /static {
		proxy_pass http://localhost:8080;
		try_files $uri $uri/ =404; # static asset directory
	}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;activate-nginx-server-block&quot;&gt;Activate NGINX Server Block&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo ln -s /etc/nginx/sites-available/my_domain /etc/nginx/sites-enabled/
sudo nano /etc/nginx/nginx.conf
http {
    server_names_hash_bucket_size 64; # &amp;lt;- uncomment this line
}
sudo nginx -t
sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;enable--setup-firewall&quot;&gt;Enable &amp;amp; Setup firewall&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo ufw enable
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw status
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install--setup-lets-encrypt&quot;&gt;&lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-22-04&quot;&gt;Install &amp;amp; Setup Let’s Encrypt&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d my_domain.com -d www.my_domain.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;confirm-automatic-ssl-cert-renewal&quot;&gt;Confirm automatic SSL cert renewal&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo systemctl status snap.certbot.renew.service
sudo certbot renew --dry-run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;update-iptables-to-redirect-80443-traffic-to-the-ports-our-node-app-will-be-running-on&quot;&gt;Update iptables to redirect 80/443 traffic to the ports our node app will be running on&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
sudo sh -c &quot;iptables-save &amp;gt; /etc/iptables.rules&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install-pm2-globally-to-run--monitor-our-node-apps&quot;&gt;Install PM2 globally to run &amp;amp; monitor our Node apps&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install pm2@latest -g
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;set-the-servers-timezone&quot;&gt;Set the Server’s Timezone&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo timedatectl set-timezone America/Los_Angeles
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
          <pubDate>2024-01-08T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/Node-MongoDB-Server-Setup-Ubuntu-22.04-LTS</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/Node-MongoDB-Server-Setup-Ubuntu-22.04-LTS</guid>
        </item>
      
    
      
        <item>
          <title>Install NodeJS 16.17</title>
          <description>&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; gcc-c++ make curl
curl &lt;span class=&quot;nt&quot;&gt;-sL&lt;/span&gt; https://rpm.nodesource.com/setup_16.x | &lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-E&lt;/span&gt; bash -

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum list available nodejs
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; nodejs
node &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
npm &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;nodejs-lts&quot;&gt;Node.js LTS&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; gcc-c++ make curl
curl &lt;span class=&quot;nt&quot;&gt;-sL&lt;/span&gt; https://rpm.nodesource.com/setup_lts.x | bash -
&lt;span class=&quot;c&quot;&gt;# Remove old version&lt;/span&gt;
yum remove &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; nodejs npm
&lt;span class=&quot;c&quot;&gt;# Clear cache&lt;/span&gt;
yum clean all
&lt;span class=&quot;c&quot;&gt;# Install new Node.js&lt;/span&gt;
yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; nodejs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;remove-nodejs&quot;&gt;Remove NodeJS&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum remove &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; nodejs
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /var/cache/yum
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; /etc/yum.repos.d/nodesource&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum clean all
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;remove-residual-files&quot;&gt;Remove residual files&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;whereis node
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rfv&lt;/span&gt; /usr/bin/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rfv&lt;/span&gt; /usr/bin/npm /usr/local/bin/npm /usr/share/man/man1/npm.1.gz
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rfv&lt;/span&gt; /usr/local/bin/npx
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rfv&lt;/span&gt; /usr/local/lib/node&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rfv&lt;/span&gt; /usr/local/include/node&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rfv&lt;/span&gt; /usr/lib/node_modules/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
          <pubDate>2024-01-05T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/install-nodejs-centos-7</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/install-nodejs-centos-7</guid>
        </item>
      
    
      
        <item>
          <title>how to run apache and node.js together the right way</title>
          <description>&lt;h3 id=&quot;step-1&quot;&gt;Step 1&lt;/h3&gt;

&lt;p&gt;Get a VPS that offers &lt;strong&gt;2&lt;/strong&gt; or more IP addresses.&lt;/p&gt;

&lt;h3 id=&quot;step-2&quot;&gt;Step 2&lt;/h3&gt;

&lt;p&gt;From the WHM cPanel, find the menu item &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Service Configuration&lt;/code&gt;, select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Apache Configuration&lt;/code&gt; and then click on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Reserved IPs Editor&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;step-3&quot;&gt;Step 3&lt;/h3&gt;

&lt;p&gt;Tick the IP address you &lt;strong&gt;DON’T WANT&lt;/strong&gt; Apache to listen to, and write it down so you can use it in the next step. Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Save&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;step-4&quot;&gt;Step 4&lt;/h3&gt;

&lt;p&gt;Install Node.js, and create a server like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello, world!');
});

server.listen(80, '111.111.111.111');
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Replacing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;111.111.111.111&lt;/code&gt; with the IP address you previously reserved from the WHM cPanel.&lt;/p&gt;

&lt;h3 id=&quot;step-5&quot;&gt;Step 5&lt;/h3&gt;

&lt;p&gt;Stop wasting your time and never listen to those telling you to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mod_rewrite&lt;/code&gt; to proxy Node.js again.&lt;/p&gt;
</description>
          <pubDate>2024-01-03T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/how-to-run-apache-and-node.js-together-the-right-way</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/how-to-run-apache-and-node.js-together-the-right-way</guid>
        </item>
      
    
      
        <item>
          <title>How to deploy NodeJS App to EC2</title>
          <description>&lt;h3 id=&quot;instructions&quot;&gt;Instructions&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;Connect to ec2 via ssh&lt;/li&gt;
  &lt;li&gt;Install nvm: https://github.com/nvm-sh/nvm via curl e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Source nvm: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;. ~/.nvm/nvm.sh&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Install node: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm install &amp;lt;your_version&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Install git: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo yum install -y git&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Git clone your project and cd in&lt;/li&gt;
  &lt;li&gt;Install yarn: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm i -g yarn&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Install your node app&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch ~/.env&lt;/code&gt; and paste your env config there with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export&lt;/code&gt; prefix&lt;/li&gt;
  &lt;li&gt;Source .env in bash_profile to run everytime: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim ~/.bash_profile&lt;/code&gt; and then add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source ~/.env&lt;/code&gt; to the bottom of the bashprofile. Source your bash_profile: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source ~/.bash_profile&lt;/code&gt; to load the new changes.&lt;/li&gt;
  &lt;li&gt;Run the server by doing yarn dev. You should be running on port 3000 at this point&lt;/li&gt;
  &lt;li&gt;From the EC2, go to the related security group and open port 3000 to 0.0.0.0/0&lt;/li&gt;
  &lt;li&gt;Test the url by going to the EC2 instance and getting the public IPv4 address. Append :3000 to the end of the url. Ensure that the url is http not https&lt;/li&gt;
  &lt;li&gt;Install pm2: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm install -g pm2&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Set up pm2 to start the server auto: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pm2 start npm -- start; pm2 save; pm2 startup&lt;/code&gt;. Copy and paste the generated script into the console to save the startup script.&lt;/li&gt;
  &lt;li&gt;Also setup logging with timestamp by doing: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pm2 restart 0 --log-date-format &quot;DD-MM-YYYY HH:MM Z&quot;&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pm2 save&lt;/code&gt;. In future, to view logs in EC2, do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pm2 logs npm&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;In EC2 security group, add inbound rule for your node port&lt;/li&gt;
  &lt;li&gt;Add classic load balancer to route port 80/443 to your port with :80:3000 and :443-&amp;gt;:3000&lt;/li&gt;
  &lt;li&gt;Create a new security group for this load balancer, exposing ports 80 and 443 only.&lt;/li&gt;
  &lt;li&gt;Create a new ACM certificate with the desired domain and validate via DNS. Open the accordion to find a button that automatically helps create a record in Route53 to validate it immediately.&lt;/li&gt;
  &lt;li&gt;For healthcheck, set protocol to http, port to 3000, and path to /&lt;/li&gt;
  &lt;li&gt;Once the load balancer is created, wait for instance status to be InService, then open the load balancer’s DNS name in the browser to test that it works.&lt;/li&gt;
  &lt;li&gt;In route 53, add A record (use the wizard) with alias to your load balancer.&lt;/li&gt;
  &lt;li&gt;Test the route, it should work.&lt;/li&gt;
  &lt;li&gt;To redirect http traffic to https, upgrade the classic load balancer to application load balancer via the migration tab.&lt;/li&gt;
  &lt;li&gt;In the new application load balancer, go to listeners and edit rules for port 80. In the rules page, click the edit pencil icon at the top and later at the bottom-left. Delete the existing ‘Then’ rule to add another action to “Redirect to” to 443 with a 301 redirect. Hit save and update for permanent http to https redirect to take effect.&lt;/li&gt;
  &lt;li&gt;Go to Route53 and point to the new application load balancer. Once done, delete the classic load balancer.&lt;/li&gt;
  &lt;li&gt;Done!&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;references&quot;&gt;References:&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;EC2 Tutorial: https://hackernoon.com/deploying-a-node-app-on-amazon-ec2-d2fb9a6757eb&lt;/li&gt;
  &lt;li&gt;ELB Tutorial: https://medium.com/tfogo/how-to-serve-your-website-on-port-80-or-443-using-aws-load-balancers-a3b84781d730&lt;/li&gt;
  &lt;li&gt;Add Env: https://mrngoitall.net/blog/2013/10/13/best-practices-on-deploying-node-dot-js-to-aws-ec2/&lt;/li&gt;
  &lt;li&gt;Route 53 to Load Balancer: https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/using-domain-names-with-elb.html?icmpid=docs_elb_console&lt;/li&gt;
&lt;/ul&gt;
</description>
          <pubDate>2024-01-02T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/ec2-node-app</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/ec2-node-app</guid>
        </item>
      
    
      
        <item>
          <title>Installing Node.js with `nvm` to Linux &amp; macOS &amp; WSL</title>
          <description>&lt;p&gt;A quick guide on how to setup Node.js development environment.&lt;/p&gt;

&lt;h2 id=&quot;install-nvm-for-managing-nodejs-versions&quot;&gt;Install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt; for managing Node.js versions&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/nvm-sh/nvm&quot;&gt;nvm&lt;/a&gt; allows installing several versions of Node.js to the same system. Sometimes applications require a certain versions of Node.js to work. Having the flexibility of using specific versions can help.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open new &lt;em&gt;Terminal&lt;/em&gt; window.&lt;/li&gt;
  &lt;li&gt;Run &lt;a href=&quot;https://github.com/nvm-sh/nvm&quot;&gt;nvm&lt;/a&gt; installer. (If you already had it, remember to update to more recent versions.)
    &lt;ul&gt;
      &lt;li&gt;… with &lt;em&gt;either&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt; &lt;em&gt;or&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget&lt;/code&gt;, depending on what your computer has available.
        &lt;ul&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash&lt;/code&gt;&lt;/li&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash&lt;/code&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;The script clones the nvm repository to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.nvm&lt;/code&gt; and adds the source line to your profile (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bash_profile&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc,&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.profile,&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bashrc&lt;/code&gt;). (You can add the source loading line manually, if the automated install tool does not add it for you.)&lt;/p&gt;

        &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;NVM_DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/.nvm&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/nvm.sh&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/nvm.sh&quot;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# This loads nvm&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/bash_completion&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/bash_completion&quot;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# This loads nvm bash_completion&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Another option: when you have consistent directory location between systems, following example Bash/Zsh configuration allows to load &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt; when the directory exists.
This allows more consistent sharing of your shell configuration between systems, improving reliability of rest of your configuration even when nvm does not exist on a specific system.&lt;/p&gt;

        &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/.nvm&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# export NVM_DIR=&quot;$([ -z &quot;${XDG_CONFIG_HOME-}&quot; ] &amp;amp;&amp;amp; printf %s &quot;${HOME}/.nvm&quot; || printf %s &quot;${XDG_CONFIG_HOME}/nvm&quot;)&quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;NVM_DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/.nvm&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# This loads nvm&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/nvm.sh&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/nvm.sh&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# This loads nvm bash_completion&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/bash_completion&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NVM_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/bash_completion&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;If everything went well, you should now either open a new Terminal window/tab, or reload the shell configuration by running:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source ~/.bashrc&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Verify installation
    &lt;ul&gt;
      &lt;li&gt;To check if nvm command got installed, run:
        &lt;ul&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command -v nvm&lt;/code&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;install-nodejs-with-nvm&quot;&gt;Install Node.js with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt;&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;List installed Node.js versions with:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm ls&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Install latest LTS Version of &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;Node.js&lt;/a&gt;&lt;/strong&gt; (for production quality applications)
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm install v20.11.1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Install latest &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;Node.js&lt;/a&gt; Current release (for testing new feature improvements)
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm install v21.6.2&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;If you want to change the default Node version later, you can run a command to adjust it.
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm alias default v20.11.1&lt;/code&gt; &lt;a href=&quot;https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#20.11.1&quot;&gt;changelog&lt;/a&gt; (for &lt;em&gt;production quality&lt;/em&gt; applications)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm alias default v21.6.2&lt;/code&gt; &lt;a href=&quot;https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V21.md#21.6.2&quot;&gt;changelog&lt;/a&gt; (if you use Node.js features from the &lt;em&gt;Current&lt;/em&gt; release)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can select Node.js version by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm use v20.11.1&lt;/code&gt; (or another version number). Another alternative: create a small Bash shell script to enable the right environment variables for your project.&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Read the Node.js [Long Term Support (LTS) schedule](https://nodejs.org/en/about/releases/ “Releases&lt;/td&gt;
      &lt;td&gt;Node.js”) to have more understanding of their release roadmap. List of all [previous releases](https://nodejs.org/en/download/releases/ “Previous Releases&lt;/td&gt;
      &lt;td&gt;Node.js”) is also useful for finding details about Node.js release history.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;a href=&quot;https://www.npmjs.com/&quot;&gt;npm&lt;/a&gt; package repository has a lot of packages to discover.
Have a good time with the freshly installed tools.&lt;/p&gt;

&lt;h2 id=&quot;migrating-packages-from-a-previous-nodejs-version&quot;&gt;Migrating packages from a previous Node.js version&lt;/h2&gt;

&lt;p&gt;If you already have existing Node.js version via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt;, you can migrate older packages from the installed Node.js versions.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Open new Terminal window (to make sure you have latest Node.js version active in your command line environment).&lt;/li&gt;
  &lt;li&gt;Before running next commands, remember to switch to the right version of Node with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm use&lt;/code&gt; command.
For example:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm use v20.11.1&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm use v21.6.2&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Linking global packages from previous version:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm reinstall-packages v20.3.1&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm reinstall-packages v18.16.1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;deleting-old-nodejs-versions&quot;&gt;Deleting old Node.js versions&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Check installed Node.js versions with:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm ls&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Delete an older version (if you don’t use it in some of your projects):
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm uninstall v20.3.1&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm uninstall v18.16.1&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;updating-outdated-packages&quot;&gt;Updating outdated packages&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Warning:&lt;/em&gt; Make sure you have latest &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nvm&lt;/code&gt; version installed, just in case. Update instructions of it in the beginning of this article. &lt;a href=&quot;https://github.com/nvm-sh/nvm/releases/tag/v0.39.2&quot;&gt;nvm &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v0.39.2&lt;/code&gt;&lt;/a&gt; version of  fixes potential problems that might cause older node environments to break if accidentally installing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm v9&lt;/code&gt; to those.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;list-of-globally-installed-top-level-packages&quot;&gt;List of globally installed top level packages&lt;/h4&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;list-outdated-global-packages&quot;&gt;List outdated global packages&lt;/h4&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm outdated &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;updating-all-globally-installed-npm-packages&quot;&gt;Updating all globally installed npm packages&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Warning:&lt;/em&gt; &lt;strong&gt;This might be too risky approach.&lt;/strong&gt; Instead, it is better to update packages individually, as that avoids the risk of accidentally updating &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm&lt;/code&gt; package to incompatible versions. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm v9&lt;/code&gt; installation to older incompatible Node.js environments is known to cause problems (potentially breaking down the development environment), so it’s better be safe than sorry.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm update &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h4 id=&quot;cli-aliases-for-bash--zsh-environments&quot;&gt;CLI aliases for Bash &amp;amp; Zsh environments&lt;/h4&gt;

&lt;p&gt;Example configuration for your Bash &amp;amp; Zsh command line environments.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;c&quot;&gt;# -----------------------------------------------------------&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# npm helpers&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# -----------------------------------------------------------&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# List what (top level) packages are installed globally&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;list-installed-npm-packages&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;npm ls -g --depth=0.&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# List what globally installed packages are outdated&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;list-outdated-npm-packages&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;npm outdated -g --depth=0.&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Update outdated globally installed npm packages&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;update-npm-packages&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;npm update -g&quot;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;fixing-old-package-versions&quot;&gt;Fixing old package versions&lt;/h4&gt;

&lt;p&gt;If you have older npm packages with compiled native extensions, recompiling native extensions can improve compatibility with the new Node.js version. Go to your project’s root directory, and run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm rebuild&lt;/code&gt; command.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;PROJECT_NAME
npm rebuild
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;notes-about-this-documentation&quot;&gt;Notes about this documentation&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/d2s&quot; title=&quot;GitHub profile of Daniel Schildt&quot;&gt;@d2s&lt;/a&gt; tested older versions of these install instructions with:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.debian.org/News/2021/20211218&quot;&gt;Debian 11.2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.debian.org/News/2019/20190706&quot;&gt;Debian 10&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/wsl/about&quot;&gt;Ubuntu on WSL2 (Windows Subsystem for Linux)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://releases.ubuntu.com/bionic/&quot;&gt;Ubuntu 20.04 LTS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://releases.ubuntu.com/jammy/&quot;&gt;Ubuntu 22.04 LTS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;contributions&quot;&gt;Contributions&lt;/h2&gt;

&lt;p&gt;If you have improvement suggestions to make these instructions simpler &amp;amp; better, post a comment under the &lt;a href=&quot;https://gist.github.com/d2s/372b5943bce17b964a79&quot; title=&quot;Installing Node.js to Linux &amp;amp; macOS &amp;amp; WSL with nvm&quot;&gt;original Gist by @d2s&lt;/a&gt; with your documentation improvement suggestions. If you are reading a forked version of the document, check the original Gist for a more recent instructions.&lt;/p&gt;
</description>
          <pubDate>2023-01-04T00:00:00+08:00</pubDate>
          <link>https://reecoverasble.github.io/installing-node-with-nvm</link>
          <guid isPermaLink="true">https://reecoverasble.github.io/installing-node-with-nvm</guid>
        </item>
      
    
  </channel>
</rss>
