All right.
So this lesson is for Windows users to install and set up for Internet Computer development,
and it's a little bit long, I have to admit.
If you take a look at the doc, which I link to in this current Udemy lesson, then you'll see that
it's got quite a few pages that we have to get through in order to be able to get up and running for
working with Windows and the Internet Computer.
But don't worry, I'm going to guide you step by step through everything that you need to do.
And even though it's quite long, as long as you follow the steps in the doc and watch the video before
you start, then it should be okay.
And if there's any changes down the line, I'll be updating this doc, so don't worry too much about
that.
Now, the first thing we need to do is to make sure that we've got the correct system requirements.
So if you go into the start section and search for system information, then you can see what the OS
version is, you're running.
So at a minimum, you should be running Windows 10, version 2004 or above, and you can tell that that's
correct version
by looking at this version and seeing that it's 19041 or above and I've got 19044 here, so that's
perfect.
And also, if you're running Windows 11 or above, that's totally fine.
The second thing to check is to make sure that you're running 64 bit Windows.
So under system type you should see x64.
Unfortunately, it's not going to work very well with 32 bit.
So these are the two requirements.
Next, you're going to go and search for PowerShell and make sure that you open it as an administrator.
This is really important.
We're going to copy this line from the guideline docs and we're just going to paste it in.
It's just "wsl --install", but is easy to paste in so you don't make any typos. And it's going
to install something called the Windows sub machine for Linux.
Basically, it's going to give us a virtual Linux to work with allowing us to run up bash commands,
which are required when we're working with the Dfinity Internet Computer.
So this is going to take a little while to run, but once it's done, it'll tell you the request operation
is successful, but you have to restart your machine for it to take effect.
So go ahead and restart your computer.
And once it has restarted and launched again, it should automatically bring up this pane where you
need to set up a username and password for working with Ubuntu.
So go ahead and enter those pieces of information.
But remember when you type your password, it's not going to show up on screen.
So just be sure you know what you're typing and maybe keep it simple as well because we're going to
be using this password very, very shortly when we're installing other components.
Now, once that is complete, go ahead and open up Windows PowerShell as the administrator again.
And I want you to run the command that you see in the installation guide.
And this basically just checks to make sure that wsl was correctly installed.
As long as you see Ubuntu version 2 listed here,
you're ready to go to the next step, which is to install Visual Studio Code.
So head over to the link that I've got for you in the installation guide,
and once you are there, you should be able to download the latest stable version of VS Code.
And then we can go ahead and click on the Download to install it.
Now go through the installation wizard, accepting the agreement, choosing all of the defaults, and
make sure that you add a desktop icon so we can access Visual Studio Code quickly.
Now, once the installation has completed, it will automatically launch.
And what we're going to do is we're going to install some required extensions to VS Code.
So head over to the installation guide and copy the first link for the Motoko extension and paste it
into the browser.
And if you click on Install in your browser, then it should be able to bring up Visual Studio Code
and allow you to open that link inside VS Code.
Now the reason is because there's quite a few extensions called Motoko, but we want the one that's from
the Dfinity Foundation.
And then we're going to install our remote wsl, which is going to allow us to use the terminal inside
VS Code and tap into that wsl that we installed earlier on.
Now finally we're ready to go ahead and install Node into wsl.
So this means that even if you have installed Node before on your Windows computer, you have to do
this again, just so that we can work with wsl, and Node, and Dfinity, and everything else.
So either over to the Homebrew link that's in the installation guide or simply just copy that command
and open up Ubuntu from the start menu and paste that command in and run it During the installation
process, it's going to ask you for the password that you set just a moment ago when you set up a Ubuntu
and you just need to type that in right now. When they ask you to confirm also go ahead and
hit Enter.
Now once it's done installing homebrew, there's two steps that you have to complete and they show you
this in the Next Steps Section.
Basically, this is going to make homebrew available to use in the PATH,
it doesn't really matter if you don't understand what that means.
It's just a little bit of manual setup that's required.
And finally, add that part that's underneath the Install Homebrew Dependencies,
enter your password and type 'Y' when they ask you to and let it go through the full installation process.
Now once you see that dollar sign again, that means it's all done and we can now check and make sure
by typing in "brew --version".
And if you see homebrew followed by some sort of version number, then that means everything was successful.
Now finally, we're going to use Homebrew to install Node version 16.
This is the latest stable version and this is the version that will work with the Internet Computer.
So it's really important that you follow this command.
Now, if you get this error that I've got,
node@16 is keg-only, which means it was not symlinked,
this is because you have another Node version installed on your computer, and all you have to do is simply
type, "brew link node@16" in order to link to this version that we just installed.
And now you can type "node --version",
and as long as you get a version that starts with 16, then you are ready to roll.
Now finally, we're ready to install DFX, so go ahead and copy that line of code that you see on
the installation guide and paste it into the Ubuntu command line.
Now it's going to take a little while to fetch dfx which is the package that's going to allow us to
work with the Internet Computer locally. Once it has installed, then it's going to tell you where it
was installed, and we have to manually set up the path to point to that location.
So in the installation guide, I've got this stub for you which I want you to paste into Notepad and
replace the part which says "REPLACE WITH YOUR INSTALLATION PATH" you got from
the dfx install.
So copy that, paste that in there, make sure there's no space between the colon and the first forward
slash.
Copy that entire command,
paste it back into Ubuntu, hit Enter to run that command.
And now if you copy that line where it says echo and then a bunch of symbols, you should be able to
see that your dfx location was added to your path like I've got here.
Now, finally run "dfx --version", and you should see dfx 0.9.3.
And if you do, then that means dfx was successfully installed and you're ready to finally get started
by creating your first Internet Computer application.
So open up VS Code and click on that little green icon to the bottom left and select New WSL Window.
Now, once you've done that, you can close down the previous window if you want, but make sure that
the window that you're working with says WSL: Ubuntu.
And if you hover over it, it should say, Running in Ubuntu.
Now go ahead and open up Ubuntu from the start menu again and we're going to create a directory called
ic-projects.
So you can either paste this command in from the installation instructions or you can type it out.
But we're basically creating this folder called ic-projects inside our main user folder, and then
we're going to cd or change directory into that newly created folder.
And inside that folder where we're going to be creating all of our Internet Computer projects,
I want you to go ahead and type the command "dfx
new hello",
and this is going to build us our sample Internet computer application called Hello.
And leave it in the background to do its thing.
And once it's built, you'll see the Dfinity logo show up and we can see where our folders and files
are by using the command that you can, again, copy from the installation instructions, but it's explorer.exe .
and you can see our hello folder with all of the template files that dfx created.
And we can now go back to VS Code, and select open folder, select the ic-projects/hello.
And it should now open up our project in VS Code.
Now if you take a look inside the src folder, you'll see all the source files for this project,
and we've got our main.mo which is our Motoko file,
but at the moment, it doesn't actually have any syntax highlighting, which is what our Motoko extension
is supposed to do.
So if you head over to the extensions tab, you can see this extension is currently disabled,
and I want you to click on that button where it says, Install in WSL: Ubuntu, so that we can make it actually
available in our WSL remote.
Now finally we can head back to our main.mo and you should see all the syntax highlighting.
Now there's also some HTML files and JS files,
but we're now ready to deploy.
So go into the terminal menu and then go to new terminal.
And here I want you to write "dfx start" in order to start the local Internet Computer.
And now once you see this listing on something, something, then I want you to split out a new terminal
window by clicking on this button here and then type in "dfx deploy" in order to deploy this hello project
onto that local dfx that we just started.
Once it's done and you see a dollar sign again, you're going to type "npm start" to start up our server.
And if you scroll up, you actually see it tells you where the project is running.
So go ahead and copy that URL and paste it into your browser.
And once it loads up, you'll see your starter project, type in your name, click on the button and
you'll see the greeting show up.
And that means you have successfully installed and set up everything that's required to start developing
on the Internet Computer.
So now you're ready to head over to the next lesson and we can get started writing some code.