Windows and Dealing with node-sass, node-gyp, python2, and msb 2.0

This is the magic fix for all windows users:
TLDR: npm install --global --production windows-build-tools --vs2015

This is for all my Windows boi’s trying to use Sass in an Angular CLI project.

Image result for sad windows
There there.. it’s not all that bad.

Ever see this after running npm install ?

MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0"

yeah… sorry. It’s not that easy

See, you can install node-sass globally all you want, but it still needs to be “compiled” to work in your project local to it.

node-sass depends on node-gyp

node-gyp depends on chromium/gyp

chromium/gyp depends on python2 and MSB 2.0. And doesn’t seem too keen on changing.

node-sass and node-gyp see their fair share of flak for being at fault for depending on these outdated technologies.

In a modern world, we use Python 3 and maybe even MSB 4.0 ( Microsoft Build Tools ). MSB comes with Microsoft Visual Studio versions, but the now lost to time 2017 version of the software (now almost 3 years old) is still MSB 3.0.

So this means you’ll need to do some python version juggling to get python2 to be the active version of python. And you will need to do a ton of digging to get your hands on an old enough version of Visual Studio to get MSB 2.0 installed.

Thankfully, windows-build-tools exists as an npm package, and allows you to punch in a switch for which version you want installed. And yes, this will install Python 2 for you as well.

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

So now you should have no problem running npm install again, after installing the npm package for windows build tools.

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of