Skip to main content

1.2 Local developer environment setup

Beginner
Tutorial

A developer environment consists of tools and packages that are required to develop applications. Usually, developer environments are stored and hosted on your local computer, but there are some situations where a virtual, web-based development environment can be used. An example of this is ICP Ninja used in previous modules, which is a web-based, virtual developer environment that can be used by developers without having to set up a local environment.

Several modules in this tutorial series will use ICP Ninja for accessibility purposes. If you'd like to continue using it as your development environment, you can skip this module, however, certain projects will not be supported by ICP Ninja.

Recall that ICP Ninja projects are only deployed for 20 minutes. That means for long-term development on ICP, you will need a local environment set up with the tools detailed on this page.

Setting up a local developer environment

Confirm you have a connection to the internet

To follow along with the Developer Liftoff and develop on ICP, you will need a connection to the internet.

Why does this matter?

You will need an internet connection to download a few different tools and packages. You will also need an internet connection whenever you plan to deploy your project to the mainnet. You do not need an internet connection to deploy a project to your local canister execution environment.

Confirm you have access to a command line interface (CLI)

Open a command line interface (CLI) window. This may be referred to as 'Terminal' or 'Shell' depending on your computer's operating system. In this documentation, this is often referred to as the 'terminal window.'

Why does this matter?

Certain tutorials in this series require a local developer environment to use tools such as dfx and git.

Download and install Node.js

Download and install Node.js.

Why does this matter?

Node.js is used by the IC SDK to generate frontend code and dependencies.

Download and install the IC SDK

The IC SDK contains the CLI tool dfx. dfx is natively supported on Linux or macOS 12.* Monterey or later.

To install the IC SDK, first install dfxvm, a CLI tool used for installing and switching between different versions of dfx.

Download and install the latest version of dfxvm with the following command:

sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"

If you are using a machine running Apple silicon, you will need to have Rosetta installed. You can install Rosetta by running softwareupdate --install-rosetta in your terminal.

Why does this matter?

The IC SDK is composed of several components that are required for developing on the Internet Computer. These components are:

  • dfx: The CLI tool used to interact with and develop canisters on ICP. Motoko is included in the installation of dfx.
  • moc: The Motoko runtime compiler.
  • replica: The software run by each node on the network. By having an instance of this software locally, you can deploy projects to a local environment.

Options for Windows users

dfx is not natively supported on Windows. To download dfx on Windows, you will need to download the Windows Subsystem for Linux. Learn more about how to install dfx on Windows.

Not all features of dfx may be supported on WSL 2.

Download and install a code editor

To write and edit code, you will need a code editor. macOS and Linux systems come with some basic editors, such as vi or nano, but these have very limited functionality and can be hard to use.

It is recommended that you use Visual Studio Code, as it is a popular choice, and there is a Motoko extension that provides additional tools for Motoko development.

Why does this matter?

Code editors are a core component of writing and developing code.

Download and install git

Download and install git.

Why does this matter?

Many of the DFINITY public repositories are hosted on GitHub, such as the examples repository used throughout this tutorial series. It is important to install git to ensure that you can download the sample code and follow along.

Ensure all packages and tools are updated to the latest release versions

If you are installing each of these tools for the first time, you will have the most recent release versions installed.

If you previously had installed any of these tools, be sure to check the most recent release version and update them if needed.

Why does this matter?

Having the latest release version ensures that you have all of the newest features and bug fixes for each tool to ensure the most seamless developer experience.

Create a working directory

The last step in setting up our developer environment is to create a new directory for you to build in. You can create a new directory with the command:

mkdir developer_liftoff

In future modules, you'll refer to this directory as the working directory. Each project that you create will be a subdirectory of this working directory.

Why does this matter?

You'll use this working directory to contain the projects that you build throughout this series. This will help keep things organized in your local file structure.

ICP AstronautNeed help?

Did you get stuck somewhere in this tutorial, or do you feel like you need additional help understanding some of the concepts? The ICP community has several resources available for developers, like working groups and bootcamps, along with our Discord community, forum, and events such as hackathons. Here are a few to check out: