Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Setup windows

Nicolas Hoffmann edited this page Jan 7, 2021 · 4 revisions

In order to be able to run our projects on Windows, to dev or test, you will need:

  • bash
  • git
  • Node.js
  • etc.

These software are very common but not on Windows. Thanks to Microsoft a simple and very efficient solution exist WSL. You can install a small layer of GNU/Linux inside your Windows, enough to work without any issues.

Install WSL

Before installing Ubuntu on Windows or before the first run, you need to install WSL, Windows Subsystem for Linux. All needed informations are available at Install guide WSL.

  1. Open PowerShell as administrator (Menu > PowerShell > Right click + Run as administrator)
  2. Run
$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  1. Reboot when it asks you to reboot

OR

  1. Visit in settings "Programs and Features > Turn Windows features on or off"
  2. Select "Windows Subsystem for Linux"
  3. Click Ok
  4. Reboot

Install a distribution GNU/Linux - Ubuntu

Once WSL is installed, you will need an OS inside. We will install Ubuntu.

Why? Because it's the most common one, it's simple and there is tons of people able to help, and tons of pages with answers inside Google. Bref, it's easy to find documentation and solutions to any issue.

  1. Open Microsoft Store
  2. Search Run linux on windows
  3. select ubuntu

images/wsl/install-2-OS.png

  1. Click run (no need to signup it's going to download and install it)

images/wsl/install-2-progress.png images/wsl/install-2-done.png

  1. When it's done, click [Launch]

images/wsl/install-3.png

  1. Fill the username + password (no need to be the same as windows login + passoword it can be toto/123).

images/wsl/install-4.png

  1. Upgrade the system
$ sudo apt-get update && sudo apt-get upgrade

Q/A the upgrade

You can see this message during the upgrade, don't panic ! 🐬

images/wsl/question-upgrade.png

Answer [Yes] (Select it via arrow keys + press Enter)

🍾🍾🍾 It's done Let's install Node.JS now.

Install Node.JS

We're going to install Node.JS via NVM Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Because it's the most simple solution available if you want to install Node.JS and upgrade it or tests your app with diff versions of Node.JS

  1. Install nvm (Ensure this command is ok, look at the readme)
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

images/wsl/install-nvm.png

  1. Run this command (or you can close and re-open the terminal)
$ source .bashrc

It's to refresh the shell, so we can use nvm else you will have an error

images/wsl/install-nvm-error.png

  1. Run
$ nvm install --lts

images/wsl/install-nvm-ok.png

It's going to auto install Node.JS LTS and NPM. Why do we install the LTS? Because it's the LTS so you know it will work with this version of Node.JS.
Sometimes the latest version of Node.JS creates an issue, ex with the v13 it was impossible to build our apps, because of an issue with a dependency.

That's why we recommend the LTS.

Voilà it's done (⌐■_■)

Create your ssh key

Open the WSL Terminal and run:

ssh-keygen -t ed25519 -C "<your email>"

images/wsl/ssh.png

Why ed25519? -> read How To Generate ed25519 SSH Key tl;dr It's faster and more secure

Voilà

Q/A

Firewall alert on npm start

When you will run $ npm start with a project you may see this alert:

images/wsl/alert-run-node.png

it's not an issue, click [Allow access]

Error npm install: Npm ERR! Error: EACCES: permission denied, rename

I have been getting npm ERR! Error: EACCES: permission denied, rename errors when doing npm install on a project using Windows Subsystem for Linux (WSL) with Visual Studio Code (VS Code) open on the project.

I am running the extension Remote - WSL.

If I close VS Code and retry the install, then I get no errors.

The following comment on an open Issue on WSL appears to describe my issue

via

Every reportories owned by root

After installing WSL and Ubuntu, you may encounter issues due to weird 'root' user ownership for everything. Restarting your computer should solve this.

Tips

Pin it

Pin the terminal, you will use it often ;)

images/wsl/pin.png

Windows Terminal

If your system is running Windows 10 18362.0 version or above, you can check Windows Terminal.

Windows Terminal is new terminal application that enable you to open each command-line tool and shell available on your computer — Command Prompt, PowerShell, Bash with WSL, etc. — inside multiple tabs. Other features: full unicode support, GPU-accelerated text rendering, full customizability, Split panes.

Available on Microsoft Store: Windows Terminal (Preview)

images/wsl/windows-terminal-preview.png

WSL 1 and 2

Please check this comparison page.

If you want to update from WSL 1 to 2, open Powershell with admin rights and type:

wsl --list --verbose

List of WSL installed

  • Enable virtual Machine feature by typing Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
  • then set up your distrib to WSL 2 wsl --set-version <distrib name> <WSL version>, ex. wsl --set-version Ubuntu 2

If you get a message: WSL needs an update of its kernel, download the Linux Kernel update package https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi and install it. Then start again the conversion.

To set it up by default for all distribs, type wsl --set-version 2, and check again with wsl --list --verbose.

It works! 🎉

Full doc here: https://docs.microsoft.com/en-us/windows/wsl/install-win10

With WSL 2, you can browse your linux files in Explorer, open \\wsl$. You may pin it to get direct access to it. To take advantage of WSL 2, better put your files on Linux system.

Explorer... linux?!

VS Code integration

If you use VS Code, here is an extention to open a folder inside WSL: Visual Studio Code Remote Development Extension Pack

Navigate to Windows directory using WSL

cd "$(wslpath "C:\Your\Windows\Directory")"

via

Module NPM

⚠️ don't use a terminal which is not WSL, but imho it's interesting to know about this module even if we don't need it.

On Windows? Want to compile native Node modules? Install the build tools with this one-liner. Start PowerShell as Administrator and run: windows-build-tools

$ npm install --global --production windows-build-tools

Clone this wiki locally