Run Into a NPM Node-gyp Compilation Error on Windows 10? Here’s What to Do.
If you are reading this, you probably feel alone, angry, abandoned by our society. You, however, are not alone. I’m here to walk you through this journey of frustration. You have probably looked at dozens of GitHub and Stack Overflow issues, none providing you the oasis of a compiled binary.
Let’s see what we can do to help.
The error message you are probably seeing, or some variation of it (there are many:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
ion in the project property pages or by right-clicking the solution and selecting "Retarget solution".
This error can happen when you are installing a number of packages from NPM that depend on binaries being compiled in order for the package to work. One common package where this can happen is Weak, which can be apart of Phantom.
The key line is this: MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK… along with some mumbo jumbo about node-gyp.
Now, how to fix it if you are windows.
Do You Have Visual Studio Already Installed?
If you answered YES, then you need to modify your installation of Visual Studio to include the compiler for C++. Now the important thing here is to NOT INSTALL the STAND ALONE compiler. It (probably) won’t work! If you’re on 2015 or 2017, rerun the installer to modify your instance of Visual Studio and install the C++ Compiler.
If the above steps don’t work — You may need to tweak the order in which Visual Studio looks for external tools to build with.
Tools > Options > Projects and Solutions > Web Package Management
Move $(PATH) to the top of the list.
Source: https://stackoverflow.com/a/43850262/3946099 (see upvoted comment). This solution solved the problem for several colleagues.
If You Do Not Have Visual Studio Installed.
npm install --global --production windows-build-tools
windows-build-tools - :package: Install C++ Build Tools for Windows using npmgithub.com
That’s it! You’re good to go. Also, now you have Python.
In conclusion… You really only need to find out if you have Visual Studio installed. If you do, install the C++ compiler, otherwise run a simple NPM command to reach the pure bliss of stress-free NPM installs.