danielwertheim

danielwertheim


notes from a passionate developer

Developer that lives by the mantra "code is meant to be shared".

Share


Tags


Disclaimer

This is a personal blog. The opinions expressed here represent my own and not those of my employer, nor current or previous. All content is published "as is", without warranty of any kind and I don't take any responsibility and can't be liable for any claims, damages or other liabilities that might be caused by the content.

Solution to issues with node-gyp & node-sass on Windows

I was trying to setup a new project using the Angular CLI and of course when I got to the point to do yarn install or npm install I got some issues. The issues…

Daniel WertheimDaniel Wertheim

I was trying to setup a new project using the Angular CLI and of course when I got to the point to do yarn install or npm install I got some issues. The issues had to do with node-sass and me not having node-gyp and Python on my machine.

Step 1 - Python via Visual Studio

As I am a happy .NET developer (thanks Microsoft for awesome IDE's & tooling support) I have Visual Studio 2017 and 2019 installed and just added the Python stuff in there. I installed both Python v2.7 and v3.

I have NOT installed the windows-build-tools package as many suggests.

Step 2 - Environment variable

I pointed the PYTHON envorinment variable to v2.7

PYTHON=C:\Python27amd64\python.exe

Step 3 - node-gyp & npm config

npm install -g node-gyp
npm config set python "C:\Python27amd64\python.exe"
npm config set msvs_version 2017

Harvest

I was now able to do:

npm install -g @angular/cli
ng new mat-lab
    --prefix matlab
    --routing true
    --style scss
    --skip-install true
    --skip-git true
npm install

Resulting in no more build errors or what so ever. No node-gyp or node-sass issues.

Hope it helps.

//Daniel

Developer that lives by the mantra "code is meant to be shared".

View Comments