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.
–
so this happened to me on windows recently. I fix it by following the following steps using a PowerShell with admin privileges:
delete node_modules
folder
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
–
–
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"
–
–
–
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 |
–
–
–
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!!
–
–
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 
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 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:\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(...)?
–
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
–
–
–
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.
–
–
–
–
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.
–
–
–
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'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
–
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
–
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 :)
–
–
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.
–
–
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.
–
–
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
–
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