添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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 was able to detect that the problem is with internal dependency that is node-gyp v3.5.0 from node-sass v3.8.0 when i researched by visiting this about node-gyp and found the prerequisite that Python needs to be installed.

So my question is that what version of node-sass can i install to bypass this or is there a better solution as my build was running fine till this morning on the same environment.

Node v5.10.1

ERROR LOG

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python2 { [Error: not found: python2] code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python { [Error: not found: python] code: 'ENOENT' }
gyp verb could not find "python". checking python launcher 
gyp verb could not find "python". guessing location 
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at Object.failNoPython (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack     at Object.<anonymous> (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files (x86)\\Jenkins\\jobs\\NdbSite-hot-fix-Manual-PreBuild\\workspace\\src\\NdbSite.UI\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-sass
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok 
Build failed

Any thoughts are much appreciated, Thanks.

You want to install angular, so you also want the angular-cli tools, then you need python2 and on windows, you also need msbuild.exe which comes with visualstudio2017. So, you first need to install the visual studio installer tool. Then you have so much tools installed, that you need to configure the versions of your tools in npm. – bvdb Apr 8, 2021 at 6:51

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

  • delete node_modulesfolder
  • running npm install --global windows-build-tools with administrative privilege. (in my case need restart - and restart without ask!!!)
  • reinstalling node modules or node-sass with npm install
  • This is exactly the right answer. npm install --global windows-build-tools installs Python 2.7, and installs it globally (so you don't have to re-install on a per-project basis). It fixes the "can't install SASS" problem. NOTE: On windows, you must run your npm command prompt as "Administrator". – paulsm4 Nov 22, 2018 at 22:14 If you try this answer and it freezes-up when running npm, try it with windows-build-tools v4: npm install --global --production windows-build-tools@4.0.0, as described here. – Cato Minor Mar 18, 2021 at 15:26

    The error message means that it cannot locate your python executable or binary.

    In many cases, it's installed at c:\python27. if it's not installed yet, you can install it with npm install --global windows-build-tools, which will only work if it hasn't been installed yet.

    Adding it to the environment variables does not always work. A better alternative, is to just set it in the npm config.

    npm config set python "C:\Python27\python.exe"

    Please stop using python2. current version of python is 3.9. This is related to this bug that has been fixed a long time ago : fixed bug in node-gyp :github.com/nodejs/node-gyp/issues/1977 => Upgrading your node-sass version will upgrade the node-gyp version then fix the bug (if you have the latest pyhon) – pdem Jun 9, 2021 at 13:37 UPDATE 07/2021 : The best solution, I've tried all the above answers but only this worked for me. – Hashan Shalitha Jul 19, 2021 at 10:24 For macOS folks, npm config set python $(which python3) If you don't have python installed, install with brew brew install python and then run the above command – Pankaj Aug 22, 2022 at 15:27

    You need to follow the below steps to fix the error:

        1: DELETE node_modules
        2: npm install node-sass@<version-as-per-below-table>
        3. npm install
    

    Every node-sass version corresponds to a specific Node.JS build.

    Below is a quick guide for minimum and maximum support supported version of node-sass (Check updates to below table here) :

    | NodeJS  | Supported node-sass version | Node Module |
    |---------|-----------------------------|-------------|
    | Node 16 | 6.0+                        | 93          |
    | Node 15 | 5.0+                        | 88          |
    | Node 14 | 4.14+                       | 83          |
    | Node 13 | 4.13+, <5.0                 | 79          |
    | Node 12 | 4.12+                       | 72          |
    | Node 11 | 4.10+, <5.0                 | 67          |
    | Node 10 | 4.9+, <6.0                  | 64          |
    | Node 8  | 4.5.3+, <5.0                | 57          |
    | Node <8 | <5.0                        | <57         |
                    you shouldn'T recommend node-sass at all. It's deprecated. The way to go nowadays is with the dart sass compiler (npm 'sass' module)
    – leachim
                    Oct 6, 2021 at 16:40
                    You are genius! I forgot to check node-sass version in my package.json. For everyone else there whose still struggling - check all your versions! In my case node v16.13, python 3.10, node-gyp 8.3 was installed, but I forgot to change version of node-sass to 6.0.1.
    – Vladimir Titkov
                    Nov 11, 2021 at 10:39
                    This was extremely helpful.  Of course updating dependencies is always preferred, but sometimes in a pinch this is not possible.  This table allowed me to identify the appropriate node version, then use nvm to downgrade to that version to get up and running in the short term.  (On Fedora Linux 35 Workstation, for what it is worth)
    – Alexander Nied
                    Mar 12, 2022 at 20:26
    

    My machine is Windows 10, I've faced similar problems while tried to compile SASS using node-sass package. My node version is v10.16.3 and npm version is 6.9.0

    The way that I resolved the problem:

  • At first delete package-lock.json file and node_modules/ folder.
  • Open Windows PowerShell as Administrator.
  • Run the command npm i -g node-sass.
  • After that, go to the project folder and run npm install
  • And finally, run the SASS compiling script, in my case, it is npm run build:css
  • And it works!!

    npm install --global windows-build-tools erasing package-lock.json and npm i -g node-sass solved my problem; – Arthur Zennig Sep 10, 2020 at 17:48 Not an acceptable solution if your organization's practice is to not have global installations. – Jay Bienvenu Feb 23, 2021 at 20:01
  • 1 - You can't upgrade "node-sass" package!
  • Install Python 2 and modify its .exe file name.
  • Fix PATH env variable records order (details below).
  • 2 - Update node-sass package.
  • Precondition

    You updated Node.JS to the latest version (v16.13.1) on Windows 10.
    You run yarn install or npm install in your project's folder and receive an error (look below).

    Option 1. Installing of Python-2 and fixing PATH env

    See MSI installer enter image description here

    After installation Python installations

    Note! Try to reinstall the latest Node.js to x86 from x64, if you get the following error on x64. (But with x86 you could receive memory limit errors, also.)

    Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93)
    

    Resort Python records in PATH env variable

    Python 3 records must be above Python 2 records!

    Copy python.exe to python2.exe

    Option 2. Upgrading of node-sass package

    Over package.json file

    Modify package.json and run yarn install or npm install on your project's folder.
    Other files will be updated automatically.

    Before befor updating before updating in package.json

    After updating: After updating

    Or use yarn or npm CLI to do the same but it may noticeably change your .lock files.

    After updating you could realize that you need to update also sass-loader, webpack, etc.

    Error you may have (FYI)

    gyp verb check python checking for Python executable "python2" in the PATH
    gyp verb `which` failed Error: not found: python2
    gyp ERR! stack Error: Command failed: C:\Python310\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
    gyp ERR! stack   File "<string>", line 1
    gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
    gyp ERR! stack                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
                    Thanks this worked! But additionally I copied "python.exe" to "python2.exe", so python2 is in search path.
    – Aleksey Kuznetsov
                    Dec 21, 2021 at 22:22
    

    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

    Thank you so much for your efforts, i was able to find the issue that node-sass package was missing from the node-modules, checked and found that indeed version is an issue, but my one was due to connection timeout, reset-cache and it seems to be working fine for now, but yes will update node according to your fix. – Vipul Panth Aug 22, 2017 at 9:14 @nschonni I'm also facing the same error. The node version is 7.7.1 and npm is 4.1.2. Can you please help me with this. – Tanvi Garg Jan 29, 2018 at 8:15 Does this mean I need to downgrade my node? I've got node 12, and need to install node-sass 4.13. – mcv Feb 25, 2020 at 16:30

    worked fine after forcing it to the right sass version, according to the version said to be working with the right node.

    NodeJS  Minimum node-sass version   Node Module
    Node 12 4.12+   72
    Node 11 4.10+   67
    Node 10 4.9+    64
    Node 8  4.5.3+  57
    

    There was lots of other errors that seemed to be caused by the wrong sass version defined.

    Thank you! This was it for me, a colleague was using an older node version, I was using 12, so it required different versions of node-sass. I updated node-sass to 4.12 and forced my colleague to upgrade to node 12 and everything was good! – Jason Masters Sep 24, 2019 at 21:29 This pretty much sums up the problem. Node-sass versions are compatible with specific versions of nodejs. This really should have a major version bump to illustrate this. Anything lower than 4.12 won't work with node 12.14 – Robharrisaz Jan 10, 2020 at 19:58 And no version is working with node 14 on Windows x64 now. I have to downgrade to node 12 to make it work. – bonniss Apr 25, 2020 at 4:54 Just an update: Check compatibility here: npmjs.com/package/node-sass and install node-sass as per ur node version. Also if the problem persists run npm rebuild node-sass. – Gopal Mishra Sep 9, 2021 at 14:30

    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.

    @RohanDevaki Your answer is totally different because you suggest removing Python 3. While my suggestion is to leave both Python versions installed and just rename Python 2 executable. – Konstantin Lyakh Nov 5, 2020 at 12:21 @ford04 "Python", "error message", etc aren't code. You should have rejected that edit. See meta.stackoverflow.com/q/360491/4284627. – Donald Duck Nov 15, 2020 at 11:11 tried everything above, just renaming python.exe to python2.exe solved it (python path was in environment variable). now, npm install worked, thks – Ramon Veloso Oct 13, 2022 at 20:24

    it works for me after that i can able to run npm install

    in other word you need to use the latest package which can support the latest python version.

    Note: Node Saas 7.0.1 is compatible with "react-scripts": "5.0.0" if your package.json has "react-scripts": "4.0.0", then change it as

     "react-scripts": "5.0.0", 
    

    node-sass is deprecated as of October 26th, 2020

    No need to mess around with installing old versions of Python, just migrate to dart.sass

    For my ReactJS project (npm), the following steps worked for me:

  • Delete node_modules from the project

  • In package.json, remove this dependency:

    "dependencies": {
        "node-sass": "^3.0.0",
    
  • npm install --save-dev sass

  • npm install

  • Now try running your project using npm start

  • If you receive an error like "To import Sass files, you first need to install node-sass", run this command as described here:
    npm install node-sass@npm:sass

    If you're using yarn, do the equivalent commands but on the last step do this instead, as described here:
    yarn remove node-sass
    yarn add sass

    NPM: 6.9.0

    I was having a lot of trouble using node-sass and node-sass-middleware. They are interesting packages because they are widely used (millions of downloads weekly), but their githubs show a limited dependencies and coverage. I was updating an older platform I'd been working on.

    What I ended up having to do was:

    1) Manually Delete node_modules

    2) Manually Delete package-lock.json

    3) sudo npm install node-sass --unsafe-perm=true --allow-root

    4) sudo npm install node-sass-middleware --unsafe-perm=true --allow-root

    I had the following help, thanks!

    Pre-built binaries not found for grpc@1.10.1 and node@10.9.0

    Error: EACCES: permission denied when trying to install ESLint using npm

    I executed all 4 steps and but not resolved, then execute this resolved npm i -D node-sass – Arun Aug 19, 2021 at 8:16

    I'm on a Windows 11 machine, and to fix it I downloaded python27 myself, using this link: https://www.python.org/download/releases/2.7/.

    And after installed I ran this command:

    npm config set python c:\python27\python.exe
                    this is strange that this worked for me, even that my python is not installed on that path.. so strange! but it worked.
    – Suisse
                    Feb 23, 2022 at 10:43
    

    Hey I got this error resolved by following the steps

  • first I uninstalled python 3.8.6 (latest version)
  • then I installed python 2.7.1 (any Python 2 version will work, but not much older and this is recommended)
  • then I added c:\python27 to environment variables
  • my OS is windows, so I followed this link
  • It worked
  • This would only be a solution if you have no need for Python3, and no applications depending on it. – Peter Abolins Nov 3, 2020 at 7:51

    Worked for me in 2022, actually we can install python 2.7 through npm After the installation for python 2.7, we can force to run npm install with using python 2.7

  • npm install --global windows-build-tools --save
  • npm install --python=python2.7
  • I had node 15.x.x , and "node-sass": "^4.11.0". I saw in the release notes from node-sass and saw the node higest version compatible with node-sass 4.11.0 was 11, so I uninstalled node and reinstall 11.15.0 version (I'm working with Windows). Check node-sass releases. (this is what you should see in the node-sass releases.)

    Hope that helps and sorry for my english :)

    Thanks much, switching to node 11.15.0 it worked. Additional to this I had uninstalled my python version 3 and switched to python 2. Not sure if both caused it to work out – techloris_109 Mar 4, 2021 at 14:53 This was the solution for me, thank you! (I use nvm so I just switched to an older version of node) – Fredrik Stolpe Sep 15, 2021 at 12:55

    Here is what helped me to prevent the error Error: not found: python2 when running a project based on the old node-gyp v3.8.0.

  • Run npm install --global --production windows-build-tools@4.0.0
  • Rename python.exe to python2.exe in %USERPROFILE%\.windows-build-tools\python27
  • Make sure that %USERPROFILE%\.windows-build-tools\python27 is part of your PATH environment variable (this is what windows-build-tools should already do for you)
  • Download Visual Studio 2017 Build Tools
  • Tell npm to use VS 2017 with npm config set msvs_version 2017
  • Run the script which uses node-gyp (node-gyp will now find python2.exe)
  • Alternative: Force upgrade of node-gyp

    You can also try to upgrade your project to use node-gyp v8.0.0 instead of node-gyp v3.8.0. In this case, add the following resolution entry to your package.json:

      "resolutions": {
        "node-gyp": "8.0.0"
    

    Afterwards, make sure that you have Python 3 installed and Visual Studio 2017 Build Tools and/or Visual Studio 2019 Build Tools. You can also run npm config delete msvs_version to let node-gyp automatically detect your VS version.

    Tested with:

  • Windows 10 Pro Build 19042.985
  • Node.js v15.14.0
  • npm v7.7.6
  • node-gyp -v v3.8.0.
  • You, sir, deserve a medal. Thanks for the "resolutions" part. It works. I think that node-sass has and old dependency of node-gyp referenced inside, trying to install an obsolete version. – Tiberiu Mihai May 3, 2022 at 7:55 This worked for me, I've been looking for hours for this! As a tip: using NVM really helps if you want to handle multiple versions of Node.js. – j3ff Aug 7, 2019 at 14:18

    We encountered this problem in 2021 when setting up a new TeamCity build agent. Originally we had installed nodejs using Chocolatey. We reinstalled going back to the original installer node-v12.12.0-x64.msi. The third screen in the installer dialog offers to install the tools necessary to compile native modules:

    After doing this our problem was gone.

    I know node-v12.12.0 is already out of date but we were trying to match other build agent machines. – Ross Presser Aug 6, 2021 at 14:57 I just did check above checkbox on a most recent NodeJS 16.6.2 install. And I still have that problem. – Frank N Aug 17, 2021 at 22:01

    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.

    Python2 maintenance status is "end of life" so it not installed by default on new ubuntu releases.

    Installing the latest python2.7 worked fine for me.

    Here is the instructions to install it:

  • download python2.7: https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
  • Install from the .tgz downloaded:
  • tar -xf Python-2.7.18.tgz
    cd Python-2.7.18
    ./configure --enable-optimizations
    sudo make altinstall
    

    Open a new terminal and try agin the npm install

    @RohanDevaki It seems like you've been suggesting a lot of edits formatting random keywords as code. Please stop. For example "Windows 10", "Node 12.19.0", "Python 64-bit", etc aren't code and shouldn't be formatted as such. See this post by a moderator. – Donald Duck Nov 15, 2020 at 11:20

    I am using Windows 11 and I had tried using npm i -g windows-build-tools but it stuck forever. So, what worked for me was:

  • Install Visual Studio Build tools 2017 from here.
  • After installing, open Powershell as admin.
  • Enter this command: npm install --global --production windows-build-tools --vs2015
  • Thank me later!
  • It fixed all errors related to build tools for me on Windows 11.

    In my case, i had node version v16 installed in the machine, but the react project used node-sass version v4.x.x, Updating the package.json with node-sass version to v6.0.1 solved the issue,
    node version support for node-sass can be checked from official npm page: https://www.npmjs.com/package/node-sass

    A simple solution for windows 11 machines is,

  • Delete package-lock.json file and node_modules/ folder.
  • Open Windows Terminal as Administrator.
  • Run the command npm i -g node-sass.
  • Go to the project folder and run npm install
  • Now run the project with npm start
  • Got this error on Windows 11 with latest Node.js LTS Version: 18.13.0 (includes npm 8.19.3)

    https://nodejs.org/en/download/

    Fixed by first downloading Python 2.7.18 manually since only Python 3.11 was installed.

    https://www.python.org/downloads/windows/

    https://www.python.org/downloads/release/python-2718/

    After install I ran the command from @bvdb:

    npm config set python "C:\Python27\python.exe"
    

    Source:

    https://stackoverflow.com/a/64486670/3850405

    This fixed the error

    If you are using Visual Studio. follow these steps:

    npm cache clean --force
    npm config set msvs_version 2019 --global
    npm install node-sass
    

    This same issue I faced few days ago. Believe on me their is no need to install or uninstall other dependencies in your project or system.

    How had I resolve this issue let me share my experience.

  • Please go to package.json file
  • Scroll down all the way below or search for optionalDependencies Object
  • Just remove this whole object & save the file
  • try npm install, it will work
  • Another Possible Solution:

    Please check your package.json file if node-sass element is exist inside the optionalDepedencies Object then you need to run npm command in this way npm install --no-optional or also If just remove node-sass element from optionalDepedencies Object

    Note: this solution is only for Angular Project

    enter image description here Please Check out this screenshot of package.json file

  •