Using NodeJS on Windows
If you’ve done NodeJS development on Windows, you might have encountered one of the following error messages when running npm install:
Can't find Python executable "python", you can set the PYTHON env variable.
Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
or some random error involving the “node-gyp rebuild” command.
You could install the correct version of .NET and Python and configure npm manually. Or you could easily install an npm module to fix this problem for you.
As an administrator run the command:
npm install -g windows-build-tools
This will download the correct version of msbuild and python for your Windows system and eliminate these build errors.
I have successfully tried this approach on both Windows 10 and Windows 7. If you have issues, let me know!
UPDATE (10/25/2018): Since writing this article, I’ve learned a few things that I think would be valuable for others. First, if you upgrade your version of npm, you will probably have to re-install windows-build-tools. Second, if you see the message “Please wait until all other operations are finished and try again.” when its installing Visual Studio Build Tools, break out of the application and retry to installation. If that doesn’t get things going again, uninstall windows-build-tools (i.e. npm uninstall -g windows-build-tools) and try again.