tl;dr
Use the msvs_version param: npm install --msvs_version=2015
What if the msvs_version param doesn't work?
If the msvs_version param doesn't work, it's probably because you don't have a Visual C++ 2015 build environment installed.
Install Visual C++ Build Environment
Option 1: Visual Studio 2015
- During VS2015 installation, select "Custom". Or, if you've already installed VS2015, go to Windows' "Uninstall or change a program" > select VS2015 from the list > click "Change" > click "Modify"
- Check the "Common Tools for Visual C++ 2015" option, under "Programming Languages" > "Visual C++"
- Finish the VS2015 installation
Option 2: Visual C++ Build Tools 2015
As an alternative to VS2015, you can install the Visual C++ Build Tools 2015 released by Microsoft:
- During VC++ installation, select "Custom"
- Check the "Windows 8.1 SDK" and "Windows 10 SDK" options
- Finish the VC++ installation
Use msvs_version
Now that a Visual C++ 2015 build environment has been installed, you can tell npm to use it via the msvs_version param:
- Open PowerShell
- Use the msvs_version param:
npm install --msvs_version=2015
Config Options (not required)
Optionally, instead of specifying the msvs_version at the command prompt, you can configure npm to always include the msvs_version param by adding it to your npmrc or package.json:
npmrc
Open PowerShell and run npm config set msvs_version 2015
, which will add this param to your user npmrc file. Henceforth, every time you run npm install
, as this user, the msvs_version=2015
param will automatically be included
optionally, you can include the global flag npm config set msvs_version 2015 --global
if you plan on logging in with different Windows accounts, and you want this setting to apply to all accounts on the machine
package.json
Modify your project's package.json file to include:
"config": {
"msvs_version": 2015
}
Henceforth, every time you run npm install
, for this project, the msvs_version=2015
param will automatically be included
Article Revisions
- Steps revised after further investigation inspired by Chuck's comment about the v120 toolset (thanks @ChuckWalbourn)
- Added config options
- Added VC++ Build Tools option
- Updated VC++ Build Tools link for official release