Skip to content

Building on Windows

Anthony Tseng edited this page Sep 12, 2016 · 12 revisions

Installing the prerequisites

Git

Here are some popular clients you can choose from:

node.js

Download link

NOTE: Please choose the CURRENT version (not the LTS version), which is 6.x (current version as of 2016 Aug 27 is 6.4.0). Also make sure you pick the right architecture for your machine (32-bit vs 64-bit)

Once the install is complete, you'll want to open a new command window to run the following:

  • npm config set python python2.7
  • npm config set msvs_version 2015 --global

Visual Studio 2015 with update 2 or newer

Download link

NOTE: If you download from the link above, you'll be OK. If you're installing from an ISO or physical media, make sure you download/install any updates (ex: update 3). Electron has an issue compiling pre-update 2.

When the installer comes up, here are the items you need installed:

  • everything under Programming Languages > Visual C++
  • Windows 10 SDK via Universal Windows App Development Tools > Windows 10 SDK
  • Windows 8.1 SDK via Windows 8.1 and Windows Phone 8.0/8.1 Tools > Tools and Windows SDKs

This install will take a while. Kick it off, take a break, and come back later to see how it's going.

OpenSSL

Download link

It's very important that you:

  • pick the correct version (32-bit or 64-bit, depending on your system)
  • don't change the install path. It must be left as the default.

NOTE: If you don't install this properly, you'll see an error like this when running npm install:

LINK : fatal error LNK1181: cannot open input file 'C:\OpenSSL-Win64\lib\libeay32.lib' [C:\Users\brian\Documents\GitHub \browser-laptop\node_modules\secp256k1\build\secp256k1.vcxproj]

Python 2.7

Download link

Make sure to add the install path to your PATH environment variable (default path is C:\Python27). A system reboot is required if the path has been added manually.

Environment variables

Here's a link with more information if you're not familiar with environment variables.

Let's create the following system variables:

  • CHANNEL = dev
  • GYP_MSVS_VERSION = 2015

Let's check the system PATH variable. Changes shouldn't be required if you followed the installer properly, but it can't hurt to check. If the values are NOT already there, you'll want to append:

  • The PATH for your Python install (default is C:\Python27)
  • The PATH for your nodejs install (default is C:\Program Files\nodejs\)

Depending on your system, a reboot may be required for these variable changes to take effect.

Getting the code

Open a new command window (make sure it's the shell you picked for your Git client). Pick a parent directory on your machine and run a git clone.

cd ~\Documents\GitHub\

# For beta testers:
git clone --depth 1 https://github.com/brave/browser-laptop

# For devs over HTTPS:
git clone https://github.com/brave/browser-laptop

# For devs over SSH:
git clone git@github.com:brave/browser-laptop.git

cd browser-laptop

Building

NOTE: If you're following this guide, please don't build Brave using Cygwin. Cygwin includes C/C++ compilers which causes complications when tasks are run which compile code (ex: npm install). Cygwin is fine to use for editing in vim, navigation, and git.

Before running this step, you may consider increasing the buffer size of your window, in case any errors show up. You can do this by right-clicking in the title and click properties (or for msys2 based shells like Git for Windows, right click > options, windows).

In your command window, at the root of the project (the browser-laptop folder), run: npm install

This step will take a while. It's going to install modules needed, some which need to be compiled from source.

You may run into errors during the npm install. There are some known issues and also some Powershell scripts to work around those known issues.

Useful scripts/tasks

To run these, you'll need to open up a new Powershell prompt and navigate to the root of your project. If you've never ran Powershell before, you'll need to enable script execution. You can do that by running: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force

NOTE: If you're on Windows 7, you may need to install Windows Management Framework (which includes a newer Powershell) before you can run the scripts.

Once you've ran that, you can run some of the scripts:

npm run win-fixnpm

This task fixes an issue with the current version of node.js and node-gyp. If you try to do an npm install without this, you'll run into the error: error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers. Of course, it's hard to see that error when npm buries that under the entire dependency tree and only shows the parent error:

npm ERR! abp-filter-cpp@1.1.14 preinstall: `npm install bloom-filter-cpp && npm install hashset-cpp`
npm ERR! Exit status 1

This script implements a fix described on Stack Overflow. Once this is ran, your npm install will now work.

NOTE: this script is safe to run multiple times; it won't modify anything unless it's necessary.

npm run win-renpm

This task will clear your ~/.electron and ./node_modules folders and re-run npm install. Useful for when new versions of electron are released.

Running

You need to open two command line windows.

  • Window 1
  • npm run watch
  • Window 2
  • npm start