How to Run a Windows Machine on Mac

Solazzo Nicola
Sep 6, 2019 · 4 min read
Image for post
Image for post

If you are a frontend developer you know how difficult is to test the code on windows especially if you are working on macOS.

There is only 1 solution to do that:

You need to create a virtual machine to run windows on your mac.

I know it can sounds difficult and you can think you need to spend a bunch of time but reading this article you will be able to set up everything 20 minutes maximum.

To do that we need to use Vagrant and VirtualBox and at the end I will like also to show you Ngrok. Let’s see how they work:

VirtualBox

VirtualBox is a free and open source software for running virtual machines able to run Windows, Linux, and others.

Vagrant

Vagrant is an open source virtual machine manager, it takes care of installing the ISO image on the virtual machine.
With Vagrant is possible to build the virtual machines that you prefer (Windows, Ubuntu, etc…).

Ngrok

Ngrok exposes local servers behind NAT and firewall to a public Internet through secure tunnels.
It provides a public URLs for exposing your local web server making it available on different devices everywhere.

Let’s start from VirtualBox

At first you need to download VirtualBox from this link: https://www.virtualbox.org/wiki/Downloads

You should see something like that:

Image for post
Image for post

Now click on OS X hosts to download it and once you have installed open VirtualBox, you shouldn’t see any virtual machine because you didn’t create any ISO image.

It’s Vagrant time

Now we need to download Vagrant from the following link: https://www.vagrantup.com/downloads.html

You should see something like that:

Image for post
Image for post

Click on macOS to download it and once you have installed go here https://app.vagrantup.com/boxes/search and search windows 10

Now you should see this:

Image for post
Image for post

Click on the first item and now you should see this page:

click on new and it will give you a command line to create your vagrantfile and to create the ISO image on VirtualBox.

Image for post
Image for post

So now open your terminal and run this command:

vagrant init senglin/win-10-enterprise-vs2015community \
--box-version 1.0.0

This command will create your Vagrantfile, the main functionality of the Vagrantfile is to describe the type of machine that you want to create (in our case windows 10).

Once you have it run:

vagrant up

This command will create your windows machine on VirtualBox based on the Vagrantfile, this command could take some time(10–15 mins) to be completed.

Now let’s run also

vagrant ssh

This command will drop you into a full-fledged SSH session, Now you can go ahead and interact with the machine and do whatever you want.

If you open VirtualBox you can see your windows machine like that

Image for post
Image for post

click on it and will open your windows machine, as password just type vagrant and voilà

But what if you want to show to somebody what we developed and we are running it on our localhost? Here Ngrok comes to help.

Last step: NGROK

Now let’s download NGROK from this url https://ngrok.com/download once you have done, unzip it and you will have a file exec, move it in your applications folder.

Now open a new window of the terminal and run:

cd /usr/local/bin

now let’s bring our ngrok file from the applications folder to the bin folder. Why that? Because we would be able to use ngrok from everywhere in our pc. So let’s run:

ln -s /Applications/ngrok ngrok

Now the cool thing happens, because we will create a public URL that you are able to navigate everywhere!

If you are listening your project locally on http://localhost:3000 (for example) with ngrok we will transform the localhost in public URL.

To do that run:

ngrok http -host-header = http://localhost:3000

and you should see something like that:

Image for post
Image for post

This is the URL generated and here you go!

NotOnlyCSS

This publication includes original articles and tips about…

Sign up for NotOnlyCSS

By NotOnlyCSS

Articles and tips for frontend developers Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Solazzo Nicola

Written by

Full-stack developer Javascript for Starteed.com

NotOnlyCSS

This publication includes original articles and tips about frontend technologies.

Solazzo Nicola

Written by

Full-stack developer Javascript for Starteed.com

NotOnlyCSS

This publication includes original articles and tips about frontend technologies.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store