Node sass python error

I get the following output when installing gulp-sass@2.0.4: $ npm install npm WARN install Couldn't install optional dependency: Unsupported npm WARN prefer global node-gyp@3.0.3 should be inst...

@glen-84

I get the following output when installing gulp-sass@2.0.4:

$ npm install
npm WARN install Couldn't install optional dependency: Unsupported
npm WARN prefer global node-gyp@3.0.3 should be installed with -g

> bufferutil@1.2.1 install D:ProgrammingGitgithubxnode_modulesbufferutil
> node-gyp rebuild


D:ProgrammingGitgithubxnode_modulesbufferutil>if not defined npm_config_node_gyp (node "C:Program Filesnodejsnode_modulesnpmbinnode-gyp-bin\....node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
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 failNoPython (C:Program Filesnodejsnode_modulesnpmnode_modulesnode-gyplibconfigure.js:116:14)
gyp ERR! stack     at C:Program Filesnodejsnode_modulesnpmnode_modulesnode-gyplibconfigure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd D:ProgrammingGitgithubxnode_modulesbufferutil
gyp ERR! node -v v4.1.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
npm WARN install:bufferutil bufferutil@1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil Exit status 1

> utf-8-validate@1.2.1 install D:ProgrammingGitgithubxnode_modulesutf-8-validate
> node-gyp rebuild


D:ProgrammingGitgithubxnode_modulesutf-8-validate>if not defined npm_config_node_gyp (node "C:Program Filesnodejsnode_modulesnpmbinnode-gyp-bin\....node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
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 failNoPython (C:Program Filesnodejsnode_modulesnpmnode_modulesnode-gyplibconfigure.js:116:14)
gyp ERR! stack     at C:Program Filesnodejsnode_modulesnpmnode_modulesnode-gyplibconfigure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd D:ProgrammingGitgithubxnode_modulesutf-8-validate
gyp ERR! node -v v4.1.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
npm WARN install:utf-8-validate utf-8-validate@1.2.1 install: `node-gyp rebuild`
npm WARN install:utf-8-validate Exit status 1

> node-sass@3.3.3 install D:ProgrammingGitgithubxnode_modulesnode-sass
> node scripts/install.js

Binary downloaded and installed at D:ProgrammingGitgithubxnode_modulesnode-sassvendorwin32-x64-46binding.node

> spawn-sync@1.0.13 postinstall D:ProgrammingGitgithubxnode_modulesspawn-sync
> node postinstall


> node-sass@3.3.3 postinstall D:ProgrammingGitgithubxnode_modulesnode-sass
> node scripts/build.js

` D:ProgrammingGitgithubxnode_modulesnode-sassvendorwin32-x64-46binding.node ` exists.
 testing binary.
Binary is fine; exiting.
npm WARN prefer global node-gyp@3.0.3 should be installed with -g

> node-sass@3.3.3 install D:ProgrammingGitgithubxnode_modulesnode-sass
> node scripts/install.js


> node-sass@3.3.3 postinstall D:ProgrammingGitgithubxnode_modulesnode-sass
> node scripts/build.js

` D:ProgrammingGitgithubxnode_modulesnode-sassvendorwin32-x64-46binding.node ` exists.
 testing binary.
Binary is fine; exiting.

> spawn-sync@1.0.13 postinstall D:ProgrammingGitgithubxnode_modulesspawn-sync
> node postinstall

Do I really have to install Python, or is this a bug?

@saper

bufferutil is not required by node-sass.

You need Python and a C++ to be able to compile native modules. Normally node-sass fetches the binary for you, if you are on a supported platform — as you see above, it downloaded fine.

But your particular problem is about https://github.com/websockets/bufferutil and not node-sass.

@glen-84

@saper

No problem! I hope you got it working anyway.

@FossPrime

Well since this was a royal pain and this is the first Google result… Here goes nothing.

If you keep getting errors on Ubuntu about python3 and python2.7 is installed and passing --python /usr/bin/python2.7 results in an arcane error when trying to install node-sass. The best way to fix it is to ignore its suggestion and just make python2.7 available as python2 in the path with something like ln -s /usr/bin/python2.7 python2

familiar python3 error

gyp ERR! stack Error: Python executable "/usr/bin/python" is v3.5.2, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

less familiar error with the suggested —python «fix»

gyp ERR! stack Error: Python executable "/bin/true" is v, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

«node-sass»: «4.5.3»

@xzyfer

Native Node JS extensions like node-sass are compiled via npm which uses node-gyp. Python is required by node-gyp. We supply a bunch of precompiled binaries with out releases so you don’t have to compile them yourself.

During the npm install process a binary is downloaded for your system. If you’re on a system we haven’t pre-compiled binaries for then npm will try to compile it for you, which is where python comes in.

Since you’re one linux there should be a binary for you. This likely means you’re running very old version of node-sass. You should always update to the latest version of a package. Please open a new issue if you continue to encounter errors with node-sass@4.5.0.

@phawxby

I’m getting the same error on Windows 10 x64. That should probably be one of the precompiled binaries considering how common it is.

@FossPrime

@phawxby @xzyfer I believe I was using npm rebuild node-sass --force since I was mounting a my repo from a mac to an ubuntu docker, the binaries would not work. Perhaps if I had just npm cache clean and npm install I would have gotten a prebuilt binary.

@xzyfer

Using the —force flag will compile the binary locally which is why you need python. Rebuild without force should fetch the appropriate binary if it’s not already present locally.

@xzyfer

@phawxby your issue is unrelated. You’re likely using an old version of node-sass with node 8. Update to 4.5.3.

@phawxby

You are correct. For some reason I was stuck on 4.5.2

@sass
sass

locked and limited conversation to collaborators

Aug 25, 2017

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00

923

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)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:13:12)
gyp  verb `which` failed     at F (C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:68:19)
gyp  verb `which` failed     at E (C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:80:29)
gyp  verb `which` failed     at C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:89:16
gyp  verb `which` failed     at C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesisexeindex.js:44:5
gyp  verb `which` failed     at C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesisexewindows.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)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:13:12)
gyp  verb `which` failed     at F (C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:68:19)
gyp  verb `which` failed     at E (C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:80:29)
gyp  verb `which` failed     at C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_moduleswhichwhich.js:89:16
gyp  verb `which` failed     at C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesisexeindex.js:44:5
gyp  verb `which` failed     at C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesisexewindows.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:Python27python.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)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesnode-gyplibconfigure.js:454:19)
gyp  ERR! stack     at  Object.<anonymous> (C:Program  Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesnode-gyplibconfigure.js:480:16)
gyp  ERR! stack     at C:Program Files  (x86)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesgraceful-fspolyfills.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)JenkinsjobsNdbSite-hot-fix-Manual-PreBuildworkspacesrcNdbSite.UInode_modulesnode-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.

Total Answers 30

33

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

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 with administrative privilege. (in my case need restart — and restart without ask!!!)
  3. reinstalling node modules or node-sass with npm install

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

mRahman

5

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

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:Python27python.exe»

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

5

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

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          |

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

3

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

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:

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

And it works!!

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

6

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

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

jidam

5

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

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:Python27python.exe to C:Python27python2.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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

2

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

I had to:

Delete node_modules
Uninstall/reinstall  node
npm install node-sass@4.12.0

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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

miraj

3

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

Two options (December 2021):

  • 1 — If you can’t upgrade the 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

After installation

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 the 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

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:Python310python.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(...)?

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

miraj

3

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

My answer might not apply to everyone.
Node version: v10.16.0
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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

raja

2

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

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:python27python.exe

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

miraj

5

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

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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

jidam

2

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

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

raja

1

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

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:

  1. Delete node_modules from the project

  2. In package.json, remove this
    dependency:

    "dependencies": {
        …,
         "node-sass": "^3.0.0",
         …
    }
    
  3. npm install —save-dev sass

  4. npm install

  5. Now try running your project using npm start

  6. 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


2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

jidam

3

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

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 :)

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

jidam

6

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

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.

  1. Run npm install --global --production windows-build-tools@4.0.0
  2. Rename python.exe to python2.exe in %USERPROFILE%.windows-build-toolspython27
  3. Make sure that %USERPROFILE%.windows-build-toolspython27 is part of your PATH environment variable (this is what windows-build-tools should already do for you)
  4. Download Visual Studio 2017 Build Tools
  5. Tell npm to use VS 2017 with npm config set msvs_version 2017
  6. 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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

3

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

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

Sass

  1. npm install --global windows-build-tools --save
  2. npm install --python=python2.7

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

5

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

had the same issue lost hours trying to install different version of python on my PC. Simply Upgrade node to the latest version v8.11.2 and npm 5.6.0, then after install node-sass@4.5.3 and you’ll be fine.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

jidam

5

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

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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

miraj

4

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

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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

3

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

In case of yarn projects, ignoring the node version with «yarn install —ignore-engines» will install any node-sass v. without these python errors

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

1

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

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

2

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

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.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

5

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

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

4

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

go to package.json and change

"node-sass": "4.14.1",

with

"node-sass": "^7.0.1",

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

in other word you need to use then 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", 

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

jidam

6

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

also you can try to use sass module instead of node-sass:

npm install sass

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

2

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

If you are using Visual Studio. follow these steps:

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

6

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

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

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

1

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

Downgrading to node 10.24.1 version with npm 6.14.12 worked for me.
Along with installing windows-build-tools using

npm i -g windows-build-tools

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

joy

2

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

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:

  1. Install Visual Studio Build tools 2017 from here.
  2. After installing, open Powershell as admin.
  3. Enter this command: npm install --global --production windows-build-tools --vs2015
  4. Thank me later!

It fixed all errors related to build tools for me on Windows 11.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

miraj

3

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

npm i npm -g will work if node version is updated. I ran into this issue, and npm install -g —production windows-build-tools worked as interim solution. But upgrading Node.js, NPM, and associated package versions is a better long term option.

2023-02-06T22:20:46+00:00 2023-02-06T22:20:46+00:00Answer Link

raja

When starting the vueJs project, use npm install to report the following errors:

npm WARN prefer global node-gyp@3.6.0 should be installed with -g

> node-sass@4.5.2 install E:workspace_vscodewwnode_modulesnode-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5                                                 .2/win32-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.2/win3                                                 2-x64-48_binding.node":

connect ETIMEDOUT 54.231.72.83:443

Timed out whilst downloading the prebuilt binary

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> node-sass@4.5.2 postinstall E:workspace_vscodewwnode_modulesnode-sass
> node scripts/build.js

Building: D:nodejsnode.exe E:workspace_vscodewwnode_modulesnode-gypbinnode-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_l                                                 dflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'D:\nodejs\node.exe',
gyp verb cli   'E:\workspace_vscode\ww\node_modules\node-gyp\bin\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using node-gyp@3.6.0
gyp info using node@6.9.5 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
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 (E:workspace_vscodeww node_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (E:workspace_vscodewwnode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (E:workspace_vscodewwnode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at E:workspace_vscodewwnode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at E:workspace_vscodewwnode_modulesisexeindex.js:42:5
gyp verb `which` failed     at E:workspace_vscodewwnode_modulesisexewindows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (E:workspace_vscodewwnode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (E:workspace_vscodewwnode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (E:workspace_vscodewwnode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at E:workspace_vscodewwnode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at E:workspace_vscodewwnode_modulesisexeindex.js:42:5
gyp verb `which` failed     at E:workspace_vscodewwnode_modulesisexewindows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:123:15) code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python D:Pythonpython.EXE
gyp verb check python version `D:Pythonpython.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.1rn"
gyp verb could not find "D:Pythonpython.EXE". checking python launcher
gyp verb could not find "D:Pythonpython.EXE". guessing location
gyp verb ensuring that file exists: C:Python27python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "D:Pythonpython.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at Object.failNoPython (E:workspace_vscodewwnode_modulesnode-gyplibconfigure.js:482:19)
gyp ERR! stack     at Object.<anonymous> (E:workspace_vscodewwnode_modulesnode-gyplibconfigure.js:508:16)
gyp ERR! stack     at E:workspace_vscodewwnode_modulesgraceful-fspolyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "D:\nodejs\node.exe" "E:\workspace_vscode\ww\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--l                                                 ibsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:workspace_vscodewwnode_modulesnode-sass
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
Build failed with error code: 1

After node scripts/install.js, I found this sentence

Cannot download «https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-51_binding.node»:

Download online, if the wrong version is the same as mine, you can use the files I downloaded. Click to download

After downloading, register it as a global environment variable in two ways:

First: Right-click my computer directly — «Attributes» — — «Advanced System Settings» — — «Environmental Variables» — — Add

The second is: set XXX = file path — «set SASS_BINARY_PATH = F: ww tools node-sass win32-x64-46_binding.

Check if the environment is appropriate: echo%SASS_BINARY_PATH%

If you print out the file address you have configured, it will be ok ay.

Finally, try installing: NPM i-g node-sass

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Node sass gyp error
  • Node pre gyp err build error
  • Node mysql error connect etimedout
  • Node must be provided when reporting error if location is not provided
  • Node js обработка ошибок

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии