Hello and welcome back to this series of articles!
Before moving on to the next articles and going deeper I wanted to make sure we were on the same track. It not the funniest part but properly set up your work environment is of major importance.
I’ve summed up the process, don’t rush it and read carefully the articles I’ve posted and everything should go fine.
If you any problem do not hesitate to post a comment and I’ll reach out as soon as possible.
I know a lot of people are using Windows, and the Dfinity SDK is not (yet) compatible with Windows. As we’ll see is not a problem thanks to something called WSL (Windows Subsystem for Linux)!
What is WSL? How can I install it?
WSL is a compatibility tool that allows us to run any Linux executable on a Windows machine. There are 2 versions: WSL 1 and WSL 2.
To run the Dfinity SDK I strongly recommend WSL 2.
There are a lot of good resources on the Internet that explain how to install WSL.
My recommendation: https://docs.microsoft.com/en-us/windows/wsl/install-win10 )
I would suggest you also go through the optional step where you install the new Windows Terminal App.
The Windows Terminal App is customizable so you can install new fonts, change the default colors, add shortcuts… but for the moment let’s stay with the default look.
What is Node JS? NPM? NVM?
Usually when you are starting you want to rush and install everything quickly.
You don’t need to know much so all subsequent explanations will be simplified but you need at least to know what NodeJS, NPM, and NVM are.
If you want to work with the “correct” setup you will need Node JS.
Moreover, NodeJS comes with a package manager called NPM: Node Package Manager which is VERY useful.
A package is a tool someone already created and uploaded online. A lot of the tool you are going to use have dependencies. A dependencie is simply a package that is needed in order to run a software.
We use different software and they all have dependencies, and maybe those dependencies have other dependencies…it quickly gets complicated.
This is why a Package Manager like NPM is very useful; as the name suggests it will take care of the packages and their dependencies for you.
Finally, NVM stands for Node Version Manager. There are a lot of different versions of Node in the real world. When you will work on different projects you will need to keep track of which version of NodeJS you are using at any point to avoid compatibilities issues.
NVM allows you to easily manage your different versions.
Install Visual Studio Code
I’m going to be really quick here.
If it’s not already done: https://code.visualstudio.com/
Visual Studio Code is perfect for newcomers and easy to use. It’s where you will write your code and do the majority of your work.
Now you are ready to install the Dfinity SDK
Copy and paste this command inside your terminal :
DFX_VERSION=0.7.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
Accept, and follow the steps.
Ready to create your first project?
Run the command: dfx new project.
It is going to create a new template project for you.
A template project is a project that is automatically generated to show you how the files are structured and all the dependencies are installed for you.
You can move inside the project using the command cd project which stands for Change Directory and then project to specify in which directory you want to move.
Using the terminal is a bit harsh at first but for the moment you just need to memorize these 3 commands.
cd for Change Directory to move between your folders. You need to specify in which folder you want to move.
ls for List Files to see all the files in the current folder .
pwd : Print Working Directoy : to know which current folder you are in.
If you ever get lost in the folder, use cd (without any folder following) and you will be brought back to your home folder.
There is a command to automatically open VS Code from the terminal, be sure to be inside the folder “project” which we just created and write “code .” it should open VS code and you can take a look at all the files we talked about in the previous article.
If you need more resources on how to set up a developer environment for Windows this video really helped me :
That’s it, we are done for today.
I hope everything went fine, next time we will move to the next level!