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 node-sass, which has native bindings that need to be compiled.

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?

Example from VS2017 installed. Credit: MSDN Blog https://blogs.msdn.microsoft.com/vcblog/2017/03/13/whats-new-with-incredibuild-and-visual-studio-2017/

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.

Go to 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.

UPDATE
If you run into the following error, see this
Github issue thread.

I recommend switching to Node 8.x if you are on Node 10.x. That may fix it right off the bat. Otherwise, the gist is:

- Delete your node_modules folder
- Update your package-lock.json file to natives@^.1.3.
-
Run npm install

gulp[3975]: ../src/node_contextify.cc:631:static void node::contextify::ContextifyScript::New(const FunctionCallbackInfo<v8::Value> &): Assertion args[1]->IsString()' failed.
1: node::Abort() [/usr/local/bin/node]
2: node::Assert(char const* const (*) [4]) [/usr/local/bin/node]
3: node::contextify::ContextifyScript::New(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
4: v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node]
5: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
6: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
7: 0x93d7aa8427d

If You Do Not Have Visual Studio Installed.

npm install --global --production windows-build-tools

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.

Developer at Knowledge Anywhere

Developer at Knowledge Anywhere