<?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: Matteo Galdi</title>
    <description>The latest articles on DEV Community by Matteo Galdi (@matteog).</description>
    <link>https://dev.to/matteog</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%2F127327%2F1d6c6c51-abf4-4601-95da-81a06e58004b.png</url>
      <title>DEV Community: Matteo Galdi</title>
      <link>https://dev.to/matteog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matteog"/>
    <language>en</language>
    <item>
      <title>WSL2 for web development</title>
      <dc:creator>Matteo Galdi</dc:creator>
      <pubDate>Thu, 03 Sep 2020 16:36:47 +0000</pubDate>
      <link>https://dev.to/matteog/wsl2-for-web-development-32kh</link>
      <guid>https://dev.to/matteog/wsl2-for-web-development-32kh</guid>
      <description>&lt;p&gt;With the release of build 18361, Windows 10 introduces a new version of his Windows Subsystem Linux. It's amazing. It works very well for me, and that's how I have done.&lt;/p&gt;

&lt;p&gt;I wouldn't say I like Windows as a development environment. I love Linux, and I love to use the terminal.  I've to say that I'm not bound to any particular kernel version or Linux distro. I like fundamental Linux utilities that speed up my routine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Windows 10 build 18361&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Part One: How to install
&lt;/h2&gt;

&lt;p&gt;Open PowerShell as admin and type as follow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you restart your computer, you can install a Linux distro downloading it on the Microsoft Store, but you will use the first version of WSL. Follow me to update.&lt;/p&gt;

&lt;p&gt;WSL 2 has  &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/compare-versions"&gt;a lot &lt;/a&gt; of improvements compared to its predecessor, to update type as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you have to set WSL 2 as the default version (it will be in the upcoming Windows versions).&lt;br&gt;
&lt;/p&gt;

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



&lt;p&gt;99% you get this error &lt;code&gt;0x1bc&lt;/code&gt; because WSL 2 runs a real Linux kernel and you don't have one, you can install it from &lt;a href="https://aka.ms/wsl2kernel"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now repeat the above command to set the default version to WSL2 finally. Restart your computer. &lt;br&gt;
Now you can install a Linux distro of your choice (&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10#install-your-linux-distribution-of-choice"&gt;here&lt;/a&gt;  all those available). I chose Ubuntu 20.04 because it has all the tools I need out of the box.&lt;br&gt;
Launch the Linux app you've just installed, follow the on-screen instructions, and enjoy your Linux distro running inside Windows. &lt;/p&gt;
&lt;h2&gt;
  
  
  Part two: Node setup
&lt;/h2&gt;

&lt;p&gt;To set up the Node environment, I highly recommend using nvm for two main reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You can easily switch between Node versions&lt;/li&gt;
&lt;li&gt;nvm installs Node in your home folder. It would be best if you never used npm with "sudo" (useful resources &lt;a href="https://dev.to/brylie/don-t-use-sudo-with-npm-install-56p9"&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To install nvm, open your WSL, move to your home directory typing &lt;code&gt;cd&lt;/code&gt; and type:&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.35.3/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now relaunch your terminal.&lt;/p&gt;

&lt;p&gt;Type &lt;code&gt;nvm&lt;/code&gt; for a list of all available commands. &lt;/p&gt;

&lt;p&gt;To install the LTS version of Node (and NPM) type as follow.&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;lts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's it. Now you can use Node and NPM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; //installs packages globally without &lt;span class="nb"&gt;sudo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
