In this tutorial, we'll take a look how to tell that the installation of this package is the problem and, importantly, also how to deal with it. For most, the error one encounters will complain either about MSBUILD version:
// npm install Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".
Or that in can't find the Python executable:
// npm install gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Luckily, both problems have a common solution.
1 Python and MSBUILD errors
There is a package called windows-build-tools which is a build tool for compiling native Node modules. It installs all the necessary tools and sets the required configuration which, trust me, saves you lots of days of cursing.
In order to install the package, run PowerShell as administrator and run the following code.
// PowerShell as administrator npm install --global --production windows-build-tools // Then for npm npm config set msvs_version 2015 --global // Or then for YARN yarn config set msvs_version 2015 --global
In many cases, this is enough. Try to re-run the installation in your project, using a regular command line again (not needed to be an administrator anymore). If different yet some errors arise again, keep on reading.
2 Windows build tools
This is a possible follow-up. In other words, this error is saying that the compiler could not find Microsoft Visuals' builder. There may be several reasons for that:
If you don't have the visual studio installed and the installation of the windows-build-tools did not help, the problem is most likely in improper registry records. First of all, locate the Cpp folder which is usually in one of following directories:
// Locating the Microsft.cpp folder For Visual studio 2015: drive:\Program Files (x86)\MSBuild\Microsoft.Cpp (x86)\v4.0\v140\ For Visual studio 2017: drive:\Program Files (x86)\Microsoft Visual Studio\year\edition\Common7\IDE\VC\VCTargets\
If it's missing, we'll try to force the installation/update of the Microsoft Visual studio manually through the windows build tools package. Locate the package (usually C:\Users\%USERNAME%\.windows-build-tools) and run the vs_BuildTools.exe inside. If you can update or install the studio, do so. Then check again if the the Microsoft.cpp folder exists.
We're almost there. Now we need to tell the MSBUILD to use default props in the located folder. To do so, we'll need to edit or create the VCTargetsPath variable in registries. Do the following:
That's it. The following steps have been enough to deal with the node-gyp and node-sass installation issues. I do hope this guide has resolved your problems as well.