Home

Awesome

Windows-Build-Tools

<a href="https://ci.appveyor.com/project/felixrieseberg/windows-build-tools"><img src="https://ci.appveyor.com/api/projects/status/gpna6y54wnfp07xr?svg=true" /></a> <a href="http://badge.fury.io/js/windows-build-tools"><img src="https://badge.fury.io/js/windows-build-tools.svg" alt="npm version" height="18"></a> <a href="https://david-dm.org/felixrieseberg/windows-build-tools"><img src="https://david-dm.org/felixrieseberg/windows-build-tools.svg" alt="dependencies" height="18px"></a> <img src="https://img.shields.io/npm/dm/windows-build-tools.svg" height="18px" />


Please note that the official Node.js for Windows installer can now automatically install the required tools. That's likely a much better option than the module listed here (windows-build-tools).


On Windows? Want to compile native Node modules? Install the build tools with this one-liner. Start PowerShell as Administrator and run:

npm install --global windows-build-tools

Or, if you are using Yarn:

yarn global add windows-build-tools

Gif

After installation, npm will automatically execute this module, which downloads and installs Visual C++ Build Tools, provided free of charge for most users by Microsoft (as part of Visual Studio Community, please consult the license to determine whether or not you're eligible). These tools are required to compile popular native modules. If not already installed, it will also install Python 3.8, configuring your machine and npm appropriately.

:bulb: [Windows Vista / 7 only] requires .NET Framework 4.5.1 (Currently not installed automatically by this package)

Both installations are conflict-free, meaning that they do not mess with existing installations of Visual Studio, C++ Build Tools, or Python. If you see anything that indicates otherwise, please file a bug.

Visual Studio 2017 vs Visual Studio 2015

This module is capable of installing either the build tools from Visual Studio 2017 or Visual Studio 2015.

By default, this tool will install the 2017 build tools. To change that, run this script with the --vs2015 parameter.

Usage

npm [--python-mirror=''] [--proxy=''] [--debug] [--strict-ssl] [--resume] [--sockets=5] [--vcc-build-tools-parameters=''] [--vs2015] [--dry-run-only] install --global windows-build-tools

Optional arguments:

Supplying Parameters to the VCC Build Tools

You can pass additional parameters directly to the VCC Build Tools installer. This tool does not check if the parameters make sense - passing incorrect parameters might break the whole installation.

Supply parameters to windows-build-tools as a JSON array. Here's quick example (note the double quotes):

npm --vcc-build-tools-parameters='[""--allWorkloads""]' install --global windows-build-tools

Visual Studio 2015 Parameters

If you run windows-build-tools with --vs2015, these parameters are available:

Visual Studio 2017 Parameters

The available parameters are documented here.

Offline Installation

By default, windows-build-tools will download the latest installers from Microsoft each time it's installed. Alternatively, you can prepare a folder that contains installers. They need to have their original names:

Then, run windows-build-tools with the --offline-installers argument:

npm install -g windows-build-tools --offline-installers="C:\Users\John\installers"

Support & Help

This package currently only handles the most common use case, none of the edge cases. If you encounter errors, we'd greatly appreciate error reports (and even pull requests). This is currently tested on Windows 10.

Node versions

Where is Python installed?

It's saved under %USERPROFILE%\.windows-build-tools\python38.

Installing as a Non-Administrator

windows-build-tools works best if installed from an account with administrative rights. However, thanks to @brucejo75, the following steps can be taken to install to a different user account:

  1. From your non-admin account (e.g. <Me>) run cmd.exe as administrator.
  2. Set the following environment variables in the new command shell:
set APPDATA=C:\Users\<Me>\AppData\Roaming
npm config set prefix C:\Users\<Me>\AppData\Roaming\npm
set USERNAME=<Me>
set USERPROFILE=C:\Users\<Me>

Ensure that the variables passed match your location of npm's roaming data and the location of user profiles on your machine. For <me>, substitute the name of the account you want to install windows-build-tools for. For more information, see the npm config set prefix description here.

  1. Run npm install -g windows-build-tools

Examples of Modules Supported

In theory, windows-build-tools supports all pure C++ addons for Node.js (and virtually everything else that requires a native compiler toolchain to be installed on your machine).

To ensure that that's true, we take a fresh Windows 10 installation, add windows-build-tools, and ensure that the most popular native Node addons compile from source. Those are: node-sass, bcrypt, sqlite3, serialport, websocket, deasync, grpc, canvas, sharp, hiredis, leveldown, nodegit, zqm, ffi, libxmljs, iconv, ref, sleep, microtime, couchbase, bignum, kerberos, and ursa.

License & Credits

The Python installation was made possible by Ali Hajimirza, who kindly wrestled with Python's MSIs until they surrendered. For details regarding the license agreements applicable to Python, see History and License 3.x.

Use of Microsoft software is subject to the terms of the corresponding license agreements. For details regarding the license agreements applicable to Visual Studio products, refer to their License Directory page. (See also this discussion for the gist of it.)

Copyright (C) 2018 Felix Rieseberg. Licensed MIT. For more details, please see LICENSE. This license applies to this package only, not to its dependencies or the 3rd party software that it installs.