474

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.

2
  • 3
    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. Commented Apr 8, 2021 at 6:51
  • Sorry , for the late reply, but this was for react js. Commented Jan 13, 2022 at 4:36

38 Answers 38

1
2
1

It was admin vs local user issue for me !

My local developer windows user account had restricted access. With temporary admin access provided by IT team, I was installing python to all users or setting the system path variables rather than setting the user path variable path which didn`t resolve the issue.

What worked for me !

After few days of trial I installed the Python2 windows installer for just the local user (Select the option as shown below)

enter image description here

and ensured that the add to path was selected, here I selected the second option Entire feature will be installed on local hard drive

enter image description here

and then doing npm install it ran without errors

Sign up to request clarification or add additional context in comments.

Comments

0

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

npm install sass

Comments

0

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

Comments

0

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

Comments

0

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.

Comments

0

My OS is Win 10 x64. The similar issue found while doing npm install.

  1. Check that the node version suits the node-sass version.(Refer to the above tables.) Upgrade or downgrade node version, if needed

  2. Delete node_modules folder

    $ npm install node-sass@

    $ npm install

Well done.

Comments

0

I tried to install windows-build-tool but somehow it was failed. The below process worked for me.

  1. Delete node_modules folder
  2. Delete yarn.lock/package-lock
  3. Run yarn add node-sass --unsafe-perm=true --allow-root or npm i node-sass --unsafe-perm=true --allow-root

Comments

-1

If you are using Visual Studio. follow these steps:

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

Comments

1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.