# Installing Microsoft MakeCode for Adafruit

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/052/768/medium800/makecode_Screenshot-2018-04-06-10_34_43.png?1523032506)

 **Microsoft MakeCode for Adafruit&nbsp;** is a web-based code editor&nbsp;for physical computing. It provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users.

If you just want to _use_ MakeCode to build programs, you can visit [https://makecode.adafruit.com/](https://makecode.adafruit.com/), and check out our [basic guide to MakeCode&nbsp;](../../../makecode)as well as instructions for [using MakeCode with the CircuitPlayground Express](../../../adafruit-circuit-playground-express/makecode).

MakeCode is built on the [Microsoft Programming Experience Toolkit (PXT)](https://github.com/Microsoft/pxt), which powers editors for a variety of hardware platforms.&nbsp; This guide offers concise instructions for installing the MakeCode for Adafruit project on a system you control.

Warning: 

# Installing Microsoft MakeCode for Adafruit

## Installing on Debian and Ubuntu Desktops

If you're using a recent stable Debian or Ubuntu release, you can install and run a development version of of MakeCode directly on your system.  (For a more contained solution that should work on Windows or MacOS, skip ahead to the next section of this guide.)

First, open a terminal and create a new directory to contain the PXT code repositories by typing the following commands:

`mkdir makecode-adafruit`
`cd makecode-adafruit`

Next, create a file called `install-makecode.sh` with `nano`, or the text editor of your choice:

`nano install-makecode.sh`

And paste the following script into the file:

```
#!/bin/sh

# Install Node.js:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install some dependencies:
sudo apt-get install git libsecret-1-dev
sudo npm install -g jake
sudo npm install -g typings
sudo npm install -g pxt

# Clone repos from GitHub:
git clone https://github.com/Microsoft/pxt
git clone https://github.com/Microsoft/pxt-common-packages
git clone https://github.com/Microsoft/pxt-adafruit

cd pxt
npm install
typings install
jake

cd ..
cd pxt-common-packages
npm install
sudo npm link ../pxt

cd ..
cd pxt-adafruit
npm install
sudo npm link ../pxt
sudo npm link ../pxt-common-packages
```

Save the file and exit (in `nano`, press **Ctrl-X**, followed by **y** and **Enter** to write the file).

The script installs Node.js, the Git version control system, and several other dependencies.  It then checks out the latest development versions of the PXT code and installs it.

Run it with:

`sh install-makecode.sh`

This should take quite a while to finish.

Now you can run the following at the command prompt:

`cd pxt-adafruit`
`pxt serve --cloud`

This step will also take quite a while the first time you run it, since it needs to build various resources.

Eventually, MakeCode should print something like the following...

```
starting local ws server at 3233...
---------------------------------------------

To launch the editor, open this URL:
http://localhost:3232/#local_token=0918998d-feec-4217-3c97-41d14634b51f&amp;wsport=3233

---------------------------------------------
opening http://localhost:3232/#local_token=0918998d-feec-4217-3c97-41d14634b51f&amp;wsport=3233
```

...and then open in your web browser:

![](https://cdn-learn.adafruit.com/assets/assets/000/052/763/medium800/makecode_Screenshot-2018-04-05-21_55_03.png?1522987841)

You can press **Ctrl-C** in the terminal to stop the MakeCode process.  To start it again, just remember to `cd` to the project directory and run `pxt serve --cloud` again:

`cd ~/makecode-adafruit/pxt-adafruit`
`pxt serve --cloud`

# Installing Microsoft MakeCode for Adafruit

## Installing with Vagrant

Vagrant is a tool for managing and configuring virtual machines. You can use it to run a development installation of MakeCode which can build the static version of the MakeCode site, like the one hosted at makecode.adafruit.com.

First, you'll need to install Vagrant, VirtualBox, and Git.&nbsp; We have a [guide to installing these tools on Windows](../../../../a-quick-linux-vm-on-windows-with-vagrant/overview).

Next, you'll need a copy of the git repository here:

[https://github.com/adafruit/Adafruit-PXT-Setup](https://github.com/adafruit/Adafruit-PXT-Setup)

Start Bash, and clone the repository:

```
git clone https://github.com/adafruit/Adafruit-PXT-Setup.git
cd Adafruit-PXT-Setup
```

Start and provision the Vagrant box:

```
vagrant up
```

This part will take a while, particularly on a slow connection, since it has to download both the image for the virtual machine and a bunch of dependencies.&nbsp; When it finishes, you should see the string "setup.sh completed" as the last message it prints out.

Now you can SSH into the Vagrant box and build MakeCode itself:

```
vagrant ssh
cd pxt-adafruit
pxt staticpkg -o /var/www/html
```

This will take a while, and may fail with a long error message on the first attempt.&nbsp; If so, run `pxt staticpkg -o /var/www/html` again.&nbsp; When it finishes, you should see something like:

```
...
rendering docs/tutorials/sensors/graph-acceleration.png
rendering docs/tutorials/sensors/graph-lightlevel.png
rendering docs/tutorials/sensors/graphblock.gif
rendering docs/tutorials/sensors/lightlevelblock.gif
rendering docs/tutorials/sensors/sensors.md
rendering docs/tutorials/siren.md
rendering docs/tutorials.md
rendering docs/windows-app-web-link-ref.json
Docs written.
```

Now, as long as the Vagrant box is running, you should be able to load MakeCode for Adafruit from your local system.&nbsp; Open up a browser and load the following URL:

[http://localhost:8080/](http://locahost:8080)

...this works because port 8080 on your system is forwarded to port 80 on the Vagrant box, which is running a webserver to serve the generated files.


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Circuit Playground Bluefruit Automatic Bike Brake Light](https://learn.adafruit.com/circuit-playground-bluefruit-brake-light.md)
- [Touch Tone for Circuit Playground Express](https://learn.adafruit.com/touch-tone-for-circuit-playground-express.md)
- [Motorized Marble Machine](https://learn.adafruit.com/marble-run.md)
- [CircuitPython I2C and SPI Under the Hood](https://learn.adafruit.com/circuitpython-basics-i2c-and-spi.md)
- [Cyberpunk Santa Eye](https://learn.adafruit.com/cyberpunk-santa-eye.md)
- [Installing CircuitPython on SAMD21 Boards](https://learn.adafruit.com/installing-circuitpython-on-samd21-boards.md)
- [Make It Plot](https://learn.adafruit.com/make-it-graph-plot.md)
- [CPX Glowing Disembodied Hand](https://learn.adafruit.com/cpx-glowing-disembodied-hand.md)
- [Make It Bubble](https://learn.adafruit.com/make-it-bubble.md)
- [Makey Paper Craft ](https://learn.adafruit.com/makey-paper-craft.md)
- [Steven Universe Cosplay Shirt & Gem](https://learn.adafruit.com/steven-universe-cosplay-shirt-gem.md)
- [MakeCode for Circuit Playground Express](https://learn.adafruit.com/makecode.md)
- [Automation with Crickit and Capsela](https://learn.adafruit.com/automation-with-crickit-and-capsela.md)
- [Trash-Built Robotic Fish](https://learn.adafruit.com/trash-robo-fish.md)
- [Circuit Playground Express Spooky Laughing Box](https://learn.adafruit.com/spooky-circuit-playground-express-mystery-box.md)
