Fixing Python and C++ issues setting up node-sass on Windows

I recently inherited a project with a Grunt-based Javascript boilerplate that carried out all the usual tasks – SASS compilation, minification etc. However, it would not install. Specifically, it seemed to be falling over installing node-sass. It would throw an error stating that Python2.7 was missing and also that the C++ MSBuild task could not be found.

Why on earth would it be looking for Python and a C++ compiler? Well it turns out one of the node-sass dependencies is node-gyp which needs to be built before it can be run and this uses Python 2.7 to be installed on the system. Also, node-sass is based upon libsass which requires a C++ compiler to be built. So now I know.

However, installing Python 2.7 did not seem to solve the initial issue, even with the PATH set in the environment variables. And the C++ task error was pointing me to install up .Net 2.0 SDK and I could do without that monumental faff.

Luckily, the solution came in a package called windows-build-tools and this took care of both issues in a single shot. Blammo!

Tags: Node.js , Grunt , Javascript
Published: 22 March 2018

Return to top