<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jonathan Noé</title>
    <description>The latest articles on DEV Community by Jonathan Noé (@noejon).</description>
    <link>https://dev.to/noejon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F200531%2F5eb2afa8-abf0-408c-8b1b-fba6bcfe0713.png</url>
      <title>DEV Community: Jonathan Noé</title>
      <link>https://dev.to/noejon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/noejon"/>
    <language>en</language>
    <item>
      <title>Copying a git repository properly</title>
      <dc:creator>Jonathan Noé</dc:creator>
      <pubDate>Tue, 31 Mar 2020 11:03:20 +0000</pubDate>
      <link>https://dev.to/noejon/copying-a-git-repository-properly-j67</link>
      <guid>https://dev.to/noejon/copying-a-git-repository-properly-j67</guid>
      <description>&lt;p&gt;G'day Internet.&lt;/p&gt;

&lt;p&gt;Two weeks ago my company migrated from Github Entreprise to Github Enterprise Cloud. All the migration went well. Only today I realised that two of my private repositories were not migrated. Luckily enough a colleague of mine pointed me towards a solution (thanks Dario). And here I share this solution with you.&lt;/p&gt;

&lt;p&gt;Making a simple copy of the repository and pushing it to a new repository in the cloud was a solution, but not a good one. Why? Because all the history of the repository is lost. Our solution does not only copy the codebase, but also the history.&lt;/p&gt;

&lt;p&gt;First we want to retrieve the old repository. In a terminal, run the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;λ git clone &lt;span class="nt"&gt;--mirror&lt;/span&gt; git@company.com/repository.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note the &lt;a href="https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---mirror"&gt;--mirror&lt;/a&gt; option: it creates a &lt;code&gt;repository.git&lt;/code&gt; folder with both the codebase and the history.&lt;/p&gt;

&lt;p&gt;Before running the next commands, we need to create an empty repository in github cloud. If you wanted to change the name of you repository, now is a good time. For this example we will keep the name &lt;code&gt;repository&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once it is create run the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;λ &lt;span class="nb"&gt;cd &lt;/span&gt;repository.git
λ git push &lt;span class="nt"&gt;--mirror&lt;/span&gt; git@github.com:company/repository.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We should now be able to see our repository in github cloud populated with the codebase and the history. &lt;/p&gt;

&lt;p&gt;When pushing to the new repo we could encounter the following error&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;! [remote rejected] refs/pull/1/head -&amp;gt; refs/pull/1/head (deny updating a hidden ref)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is likely because a &lt;a href="https://stackoverflow.com/a/34266401"&gt;pull request was opened&lt;/a&gt; in the previous repository. It does not stop the repository being copied, it just does not copy the pull request.&lt;/p&gt;

&lt;p&gt;That's all folks, I hope this helps.&lt;/p&gt;

&lt;p&gt;Jon&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Setting up a node.js development environment in WSL 2</title>
      <dc:creator>Jonathan Noé</dc:creator>
      <pubDate>Tue, 23 Jul 2019 22:09:28 +0000</pubDate>
      <link>https://dev.to/noejon/setting-up-a-node-js-development-environment-in-2-4eb1</link>
      <guid>https://dev.to/noejon/setting-up-a-node-js-development-environment-in-2-4eb1</guid>
      <description>&lt;p&gt;G'day Internet,&lt;/p&gt;

&lt;p&gt;Here we are with the first article I am releasing on the web. And today we will talk about Windows Subsystem for Linux, a feature released as part of the insider build 18917. We will attempt to install WSL2 and setup a node.js development environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/about"&gt;Windows has a Subsystem for Linux&lt;/a&gt; since 2016. It enabled us to use Linux distributions on our Windows 10 systems. It now comes with &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/wsl2-index"&gt;Windows Subsystem for Linux 2&lt;/a&gt;, with a shift in their architecture, improving both the performance and the compatibility between windows and the subsystem. Further information can be found in &lt;a href="https://devblogs.microsoft.com/commandline/"&gt;Microsoft's developer blog&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Node.js development environment
&lt;/h1&gt;

&lt;p&gt;The development environment we will set up is composed of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git&lt;/code&gt; as our version control system.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;zsh&lt;/code&gt; and &lt;code&gt;oh-my-zsh&lt;/code&gt; to replace bash (optional).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;visual studio code&lt;/code&gt; as our text editor.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;node.js&lt;/code&gt; and &lt;code&gt;npm&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docker&lt;/code&gt; and &lt;code&gt;docker-compose&lt;/code&gt; to containerise our projects .&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But first we need to install WSL2.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing WSL2
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Windows insider
&lt;/h2&gt;

&lt;p&gt;The first thing we are going to do is enable the &lt;code&gt;Windows Insider Program&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It can be enabled in the &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;Update and Security&lt;/code&gt; &amp;gt; &lt;code&gt;Windows Insider Program&lt;/code&gt;. Here are the steps &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logging in to &lt;code&gt;Windows Insider account&lt;/code&gt; or create one.&lt;/li&gt;
&lt;li&gt;At the time of writing, WSL2 is in the &lt;code&gt;Fast&lt;/code&gt; builds, so the &lt;code&gt;insider settings&lt;/code&gt; should be set to &lt;code&gt;Fast&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Then we head to &lt;code&gt;settings&lt;/code&gt; &amp;gt; &lt;code&gt;Update and Security&lt;/code&gt; &amp;gt; &lt;code&gt;Windows Update&lt;/code&gt; and check for updates. We then install the latest build, then restart our machine. &lt;/li&gt;
&lt;li&gt;We should now have the latest updates, and with that comes WSL2. Next we will see how we can activate WSL2.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  WSL
&lt;/h2&gt;

&lt;p&gt;In order to install WSL2, WSL the first needs to be installed. Open a Powershell (as an Administrator) and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;Enable-WindowsOptionalFeature&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-Online&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-FeatureName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Microsoft-Windows-Subsystem-Linux&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When prompted to restart our machine, we just answer with [Y]es.&lt;/p&gt;

&lt;p&gt;After the computer restarted, we head to &lt;code&gt;the Microsoft Store&lt;/code&gt; and search the term &lt;code&gt;linux&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After clicking on &lt;code&gt;Run Linux on Windows&lt;/code&gt; we choose to get &lt;code&gt;ubuntu&lt;/code&gt; as our linux distribution. Once ubuntu is installed, we launch it. After a first initialization we are prompted for the &lt;code&gt;Unix username&lt;/code&gt; and the &lt;code&gt;Unix password&lt;/code&gt;. We then update ubuntu's package manager (this might take some time and you will be prompted for information twice, normally).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We are now one step away from enabling WSL2.&lt;/p&gt;

&lt;h2&gt;
  
  
  WSL2
&lt;/h2&gt;

&lt;p&gt;Let's open a powershell again, and enable another optional feature&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;Enable-WindowsOptionalFeature&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-Online&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-FeatureName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;VirtualMachinePlatform&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Again, we are prompted to restart the system. [Y]es again.&lt;/p&gt;

&lt;p&gt;After the machine rebooted, we open a powershell as Administrator for the last time, to make sure that we make use of WSL2!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--set-version&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ubuntu&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This process might take a few minutes, says Powershell.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I have ran this installation on two different machines during the same week, and once I had to type &lt;code&gt;ubuntu&lt;/code&gt; and the other one &lt;code&gt;ubuntu-18.04&lt;/code&gt;. There are several ubuntus in the store, I might have picked different ones.&lt;/p&gt;

&lt;p&gt;Next we set WSL2 as our default choice for WSL&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--set-default-version&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And this is it, we have now successfully installed WSL2. Time to set up our development environment.&lt;/p&gt;

&lt;h1&gt;
  
  
  Linux files
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://devblogs.microsoft.com/commandline/wsl-2-is-now-available-in-windows-insiders/"&gt;The release announcement blogpost&lt;/a&gt; asks us "To make sure to put the files that we will be accessing frequently inside of our Linux root file system to enjoy the file performances benefits".&lt;/p&gt;

&lt;p&gt;We can now access files from the windows &lt;code&gt;explorer&lt;/code&gt;. It is as easy as typing &lt;code&gt;\\wsl$\Ubuntu\home&lt;/code&gt; in the explorer navigation bar. We are now in our home folder. &lt;br&gt;
The home folder can be pinned to &lt;code&gt;Quick access&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Most of the installation will happen in the ubuntu console. As good practice, before installing anything on linux run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can now start setting up our development environment.&lt;/p&gt;

&lt;h1&gt;
  
  
  Changing bash to zsh
&lt;/h1&gt;

&lt;p&gt;In this section we are replacing the default &lt;code&gt;bash&lt;/code&gt; terminal with &lt;code&gt;zsh&lt;/code&gt; and &lt;code&gt;oh-my-zsh&lt;/code&gt;. You can skip to the development tools section if you plan to keep use &lt;code&gt;bash&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;To install &lt;code&gt;zsh&lt;/code&gt; we open a &lt;code&gt;terminal&lt;/code&gt; (the ubuntu app) and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;zsh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;zsh&lt;/code&gt; can now be launched just by typing &lt;code&gt;zsh&lt;/code&gt; in the terminal. A &lt;code&gt;.zshrc&lt;/code&gt; file needs to be created, and we are prompted for a choice. He we pick (0) as the &lt;code&gt;.zshrc&lt;/code&gt; file will be replaced when we install &lt;code&gt;oh-my-zsh&lt;/code&gt;.&lt;br&gt;
We don't want to type zsh each and everu time we start the ubuntu app, so the next thing we want to is change the default shell to use &lt;code&gt;zsh&lt;/code&gt;. To do so, we'll use the &lt;a href="http://man7.org/linux/man-pages/man1/chsh.1.html"&gt;chsh&lt;/a&gt; command as per &lt;a href="https://askubuntu.com/questions/131823/how-to-make-zsh-the-default-shell"&gt;this example&lt;/a&gt;. Simply run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;chsh &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;which zsh&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After this is done, we will change the theme of our &lt;code&gt;zsh&lt;/code&gt; and to do so, we will leverage the power of &lt;a href="https://ohmyz.sh"&gt;oh-my-zsh&lt;/a&gt;. A simple command will install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I changed my theme to &lt;a href="https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#lambda"&gt;the lambda theme&lt;/a&gt; but feel free to choose amongst all &lt;a href="https://github.com/robbyrussell/oh-my-zsh/wiki/Themes"&gt;other existing themes&lt;/a&gt; and follow the instructions there to change.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;zsh&lt;/code&gt; also comes with a set of plugins that could be useful to increase your development speed.  Completion plugins are also available for &lt;code&gt;npm&lt;/code&gt;. Please refer to the &lt;a href="https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins"&gt;plugin page&lt;/a&gt; to find anything that suits you. I enjoy working with the &lt;a href="https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git/"&gt;git plugin&lt;/a&gt;. Talking about git, it is the next tool we are going to install.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: When running &lt;code&gt;sudo apt upgrade&lt;/code&gt; or &lt;code&gt;sudo apt-get update&lt;/code&gt;, the following error code could be encountered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;E: Release file &lt;span class="k"&gt;for &lt;/span&gt;https://download.docker.com/linux/ubuntu/dists/bionic/InRelease is not valid yet &lt;span class="o"&gt;(&lt;/span&gt;invalid &lt;span class="k"&gt;for &lt;/span&gt;another 15h 3min 13s&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; Updates &lt;span class="k"&gt;for &lt;/span&gt;this repository will not be applied.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is dues to a &lt;a href="https://github.com/microsoft/WSL/issues/4245"&gt;known issue&lt;/a&gt; in WSL. A temporary fix is to call&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;hwclock &lt;span class="nt"&gt;-s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Development tools
&lt;/h1&gt;

&lt;h2&gt;
  
  
  git
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Install
&lt;/h3&gt;

&lt;p&gt;To install git, in a wsl terminal, we run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  End of line
&lt;/h3&gt;

&lt;p&gt;The next step is to deal with cross plateform problems, where sometimes git recognise changes in files, when there are none. This is due to windows using CRLF and linux LF to signify an end of line. To fix that, the following line can be run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; core.autocrlf input
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Configuring SSH
&lt;/h3&gt;

&lt;p&gt;First we create a SSH key on your new linux subsystem. Instructions can be found (here)[&lt;a href="https://help.github.com/en/enterprise/2.15/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent"&gt;https://help.github.com/en/enterprise/2.15/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;To generate a private and a public key for git, we run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"email@email.com"&lt;/span&gt; &lt;span class="c"&gt;#replace with your email&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will generate a new ssh key. When prompted to choose a file where the key will be saved, we can use either the default location or input your preferred location for the file. For this example we will consider that we used the default location &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Start the ssh-agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We then add the ssh private key to the ssh-agent&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-add ~/.ssh/id_rsa
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After that we can add the key to a &lt;a href="https://help.github.com/en/enterprise/2.15/user/articles/adding-a-new-ssh-key-to-your-github-account"&gt;github&lt;/a&gt; or a (gitlab)[&lt;a href="https://docs.gitlab.com/ee/ssh/#adding-an-ssh-key-to-your-gitlab-account"&gt;https://docs.gitlab.com/ee/ssh/#adding-an-ssh-key-to-your-gitlab-account&lt;/a&gt;] account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I currently need to run &lt;code&gt;eval "$(ssh-agent -s)"&lt;/code&gt; and &lt;code&gt;ssh-add ~/.ssh/id_rsa&lt;/code&gt; every time I restart my laptop. &lt;/p&gt;

&lt;p&gt;Now that we installed git, we are sure that the code we write does not get lost. Now to write our code, let's install Visual Studio Code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Visual Studio Code
&lt;/h3&gt;

&lt;p&gt;We browse (the Visual Studio Code website)[&lt;a href="https://code.visualstudio.com/"&gt;https://code.visualstudio.com/&lt;/a&gt;], download visual studio code for &lt;strong&gt;Windows&lt;/strong&gt;, and install it.&lt;/p&gt;

&lt;p&gt;During the installation process, we make sure to check the box to add Visual Studio Code to the PATH, it is recommended for an extension we'll install later.&lt;/p&gt;

&lt;p&gt;Code comes with heaps of extensions, but the one we are interested in is &lt;a href="https://code.visualstudio.com/docs/remote/remote-overview"&gt;VS Code Remote Development&lt;/a&gt;. It bundles a few extensions that are useful for remote development, including &lt;code&gt;Remote - WSL&lt;/code&gt; which will do some magic for us.&lt;/p&gt;

&lt;p&gt;In VS Code, in the extension tab we look for &lt;code&gt;Remote Development&lt;/code&gt; and install it.&lt;/p&gt;

&lt;p&gt;In a &lt;code&gt;zsh&lt;/code&gt; terminal we browse to our home folder and create a &lt;code&gt;dev&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~ &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mkdir &lt;/span&gt;dev &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we just start code from a ubuntu terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;code &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It should open a new VS Code window, and install a VS Code server on our WSL. Once this is done, we can now create files in our editor and they will be created in the linux file system.&lt;br&gt;
This article is written using exactly this setup \o/&lt;/p&gt;

&lt;p&gt;This last part is for those among us who installed &lt;code&gt;zsh&lt;/code&gt;. Once VS Code is connected to WSL, it is possible to modify the default shell to be &lt;code&gt;zsh&lt;/code&gt;. This will take effect after relaunching the terminal.&lt;/p&gt;

&lt;p&gt;Now that we have installed Visual Studio Code, let's install node.js&lt;/p&gt;
&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Node Version Manager (nvm)
&lt;/h4&gt;

&lt;p&gt;To install &lt;a href="https://nodejs.org/en/"&gt;node.js&lt;/a&gt; we will leverage &lt;a href="https://github.com/nvm-sh/nvm"&gt;nvm&lt;/a&gt;. The &lt;a href="https://github.com/nvm-sh/nvm#install--update-script"&gt;installation&lt;/a&gt; is once again quite straight forward. In a ubuntu terminal we run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-o-&lt;/span&gt; https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | zsh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If you did not install &lt;code&gt;zsh&lt;/code&gt;, the previous command should be run with &lt;code&gt;bash&lt;/code&gt; instead of &lt;code&gt;zsh&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;If the installation is successful the following command should return &lt;code&gt;nvm&lt;/code&gt;. If it does not, a simple restart of the terminal should fix it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; nvm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Installing node and npm
&lt;/h4&gt;

&lt;p&gt;Let's have a look at the commands available in nvm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The command we are interested in in the &lt;code&gt;nvm install&lt;/code&gt; command. Let's install node's latest LTS (Long-term support) version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--lts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's it, we installed &lt;code&gt;node&lt;/code&gt; and &lt;code&gt;npm&lt;/code&gt;. But let's check that I am not lying by checking the versions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--version&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Our journey to set up our development environment is almost complete. The last thing we need to do is to take one last (whale-)boat trip. Here comes Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Docker CE
&lt;/h4&gt;

&lt;p&gt;To install &lt;a href="https://www.docker.com/"&gt;docker&lt;/a&gt;, we will follow the &lt;a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/"&gt;steps from the official documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First we need to update &lt;code&gt;apt-get&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After what we install a few required dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    apt-transport-https &lt;span class="se"&gt;\&lt;/span&gt;
    ca-certificates &lt;span class="se"&gt;\&lt;/span&gt;
    curl &lt;span class="se"&gt;\&lt;/span&gt;
    gnupg-agent &lt;span class="se"&gt;\&lt;/span&gt;
    software-properties-common
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We then need to add Docker's official GPG key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://download.docker.com/linux/ubuntu/gpg | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We need to make sure that we have the key with fingerprint &lt;code&gt;9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key fingerprint 0EBFCD88
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Docker needs to be added to the list of repositories&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;add-apt-repository &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="s2"&gt;"deb [arch=amd64] https://download.docker.com/linux/ubuntu &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;
   &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;lsb_release &lt;span class="nt"&gt;-cs&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;
   stable"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: My processor is an amd64 process, if you have a different type of processor, replace &lt;code&gt;[arch=amd64]&lt;/code&gt; accordingly (other possible values: &lt;code&gt;armhf&lt;/code&gt;, &lt;code&gt;arm64&lt;/code&gt;, &lt;code&gt;ppc64e1&lt;/code&gt; and &lt;code&gt;390x&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We are now ready to install (Docker Community Edition)[&lt;a href="https://docs.docker.com/install/"&gt;https://docs.docker.com/install/&lt;/a&gt;]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;docker-ce docker-ce-cli containerd.io
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now let's make sure that docker is installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;docker run hello-world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This should download a test image and run it in a container. If the docker service is not started, it needs a (manual kickstart)[&lt;a href="https://docs.docker.com/config/daemon/systemd/"&gt;https://docs.docker.com/config/daemon/systemd/&lt;/a&gt;] and in our case, with ubuntu we will use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service docker start
&lt;span class="nb"&gt;sudo &lt;/span&gt;docker run hello-world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Docker Compose
&lt;/h4&gt;

&lt;p&gt;In this world full of microservices, a tool such as &lt;a href="https://docs.docker.com/compose/"&gt;docker compose&lt;/a&gt; is a time saver. It allows us to run several application containers from one single command. &lt;a href="https://docs.docker.com/compose/install/"&gt;The installation steps&lt;/a&gt; are as follows:&lt;/p&gt;

&lt;p&gt;First download the stable release of Docker Compose (&lt;code&gt;1.24.1&lt;/code&gt; at time of writing)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="s2"&gt;"https://github.com/docker/compose/releases/download/1.24.1/docker-compose-&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;-&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once the binary is downloaded, it needs to have execution permissions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; +x /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally we check the installation by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which should return a docker-compose version and a build id (&lt;code&gt;docker-compose version 1.24.1, build xxxxxxxx&lt;/code&gt; at time of writing)&lt;/p&gt;

&lt;p&gt;We have now installed the tools for us to start developing node apps. WSL2 is currently only in beta mode, so we will most likely encounter &lt;a href="https://github.com/microsoft/WSL/issues"&gt;issues&lt;/a&gt;. Don't hesitate to report any issue encountered (double checking first if the issue has been encountered yet).&lt;/p&gt;

&lt;p&gt;I hope that you enjoyed this article, the first one I ever wrote. Feel free to leave some feedback.&lt;/p&gt;

&lt;p&gt;That's all folks!&lt;/p&gt;

&lt;p&gt;Jonathan.&lt;/p&gt;

</description>
      <category>node</category>
      <category>docker</category>
      <category>git</category>
      <category>wsl</category>
    </item>
  </channel>
</rss>
