Node.js: Python not found exception due to node-sass and node-gyp

前端 未结 12 1332
余生分开走
余生分开走 2020-12-04 15:22

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

相关标签:
12条回答
  • 2020-12-04 15:49

    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

    0 讨论(0)
  • 2020-12-04 15:51

    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.

    0 讨论(0)
  • 2020-12-04 15:51

    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.

    0 讨论(0)
  • 2020-12-04 15:53

    so this happened to me on windows recently. I fix it by following the following steps using a PowerShell with admin privileges:

    1. delete node_modulesfolder
    2. running npm install --global windows-build-tools
    3. reinstalling node modules or node-sass with npm install
    0 讨论(0)
  • 2020-12-04 15:54

    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.

    0 讨论(0)
  • 2020-12-04 15:55

    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.

    0 讨论(0)
提交回复
热议问题