If you’re here, there are a few chances that you’re probably getting an error among these lines while installing an NPM package for Node.js on Windows (most probably the node-sass package):
gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "C:\Users\<youruser>\AppData\Local\Programs\Python\Python37-32\python.EXE", you can set the PYTHON env variable. gyp ERR! stack at PythonFinder.failNoPython (C:\<project-path>\node_modules\node-gyp\lib\configure.js:483:19) gyp ERR! stack at PythonFinder.<anonymous> (C:\<project-path>\node_modules\node-gyp\lib\configure.js:508:16) gyp ERR! stack at C:\<project-path>\node_modules\graceful-fs\polyfills.js:284:29 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:158:21
The issue is caused because Node can’t find the Python path on your system.
- (optional) Install Python from the official website.
- Run the following command to install the Windows Build Tools using an elevated (Administrator) terminal window which installs the VS Build Tools and also Python 2.7:
npm install --global --production windows-build-tools
3. Install node-gyp globally as admin using the following command:
npm install node-gyp
That’s it! After the installation is complete, close and re-run (normally) the terminal window and proceed by installing the problematic package again, which should run successfully.
Let me know in the comments below what edge cases you guys encounter so I could update the article with missing details. 😁