Last modified: Fri Aug 16 2019 11:27:04 GMT+0000 (Coordinated Universal Time)

How to develop on Microsoft Windows?

Our primary development platform is Linux. If you'd like to develop, or test out our tools on Windows, this guide should help you. This guide will also help you to get truffle up and running.

Runtime environment

Node.js

Most of our and Ethereum tooling is written in JavaScript that runs in a Node.js environment. Part of this ecosystem is the npm package manager which we use to distribute our releases.

To get both of those running, just install Node from the official page. During the installation, be sure that npm is installed as well.

You can verify successful installation by running node --version and npm --version in powershell. It should return a version number.

After that, you are able to run your own instances of our tooling installed in the global npm's namespace, such as:

$ npm install -g @windingtree/wt-hotel-explorer superstatic
$  $env:WT_READ_API='https://demo-api.windingtree.com'; $env:WT_SEARCH_API='https://demo-search-api.windingtree.com'; wt-hotel-explorer

After these, you should be able to visit a http://localhost:8080 which is a default location of the web server running the Hotel Explorer instance.

Docker

The other way to run our software is by using Docker images. You will need to install Docker Desktop and once you have that, you can interact with our images like this:

$ docker pull windingtree/wt-read-api
$ docker run -p 3000:3000 -e ETH_NETWORK_PROVIDER=... -e WT_CONFIG=playground windingtree/wt-read-api

While this will work if you want to play around with our tools, it's not enough to make and test any changes.

Development environment

First off, you need to have a working git. Be sure to install Git Bash along with it, it will make the things much easier for you.

Some of our dependencies require compilation during the installation phase. For that, we need the windows-build-tools package for Node.js. Follow the instructions in node-gyp, basically run npm install --global --production windows-build-tools in a cmd or PowerShell with Administrative privileges.

The biggest difference between development on Linux and Windows is the handling of environment variables which we heavily rely on. It is possible to make everything cross platform, but we will stick with Git Bash from now on, which mimicks the environment variable handling of a Linux system.

However, there is one more command we need to run before the things start to work. This tells npm to run all scripts in a bash environment which properly interprets the environment variables. Run this in the Git Bash instance.

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

We will test things out on our Read API.

# Clone the repository
$ git clone https://github.com/windingtree/wt-read-api.git
# Jump into the directory
$ cd wt-read-api
# Install dependencies
$ npm install
# Prepare the local instance
$ npm run resolve-swagger-references
# Run a test suite
$ npm test

If none of these commands spits out any errors, you were successful! Everything should work just fine from now on. You can start with running the Read API in an isolated dev mode. First, we need to start a local Ethereum network with npm run dev-net. In a different instance of Git Bash, start the API:

$ npm run dev

If you visit the http://localhost:3000, you should see the API running. Note: There might currently be some issues with ending the processes. If you are not able to start the API again, try looking for and killing a dangling node processes in your Task manager.

Now, when you make changes to the source code, the npm test script should pick it up immediately.

The same setup works for othernpm repositories such as our smart contracts wt-contracts or our ORG.ID getting started tutorial repository.

The only culprit you can encounter with truffle is the need to rename the truffle.js to truffle-config.js on Windows.