Suddenly in one of my jenkins environment build has started failing, while in local machine it seems to be working fine as i have python installed,
From the logs i w
Node-sass tries to download the binary for you platform when installing. Node 5 is supported by 3.8 https://github.com/sass/node-sass/releases/tag/v3.8.0 If your Jenkins can't download the prebuilt binary, then you need to follow the platform requirements on Node-gyp README (Python2, VS or MSBuild, ...) If possible I'd suggest updating your Node to at least 6 since 5 isn't supported by Node anymore. If you want to upgrade to 8, you'll need to update node-sass to 4.5.3
This is 2 years old, but none of them helped me.
I uninstalled my NodeJS v12.8.1 (Current) and installed a brand new v10.16.3 (LTS) and my ng build --prod
worked.
After looking at all the answers, i notice this solution might be very helpful. It explains how to configure "npm" to find your installed python version while installing node-sass. Remember, node-sass requires node-gyp (an npm build-tool) which looks for your python path. Or just install python, and follow the same solution given (in the link). Thanks.
so this happened to me on windows recently. I fix it by following the following steps using a PowerShell with admin privileges:
node_modules
foldernpm install --global windows-build-tools
npm install
I found the same issue with Node 12.19.0 and yarn 1.22.5 on Windows 10. I fixed the problem by installing latest stable python 64-bit with adding the path to Environment Variables during python installation. After python installation, I restarted my machine for env vars.
node-gyp requires old Python 2 - link
If you don't have it installed - check other answers about installing windows-build-tools.
If you are like me and have both old and new Python versions installed, chances are that node-gyp tries to use Python 3. And that results in the following SyntaxError: invalid syntax
error.
I found an article about having two Python versions installed. And they recommend renaming Python 2.* executable to python2.exe
- link.
So it looks like node-gyp is expecting to find old Python 2 executable renamed. Hence the error message:
...
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
...
Once I renamed C:\Python27\python.exe
to C:\Python27\python2.exe
it worked without errors.
Of course, both C:\Python27\
and C:\Python39\
have to be in PATH variable. And no need in setting old Python version in npm config. Your default Python still will be the new one.