2

This is on my work laptop. I have Latest version of angular, Nodejs, Nodesass, VScode and mentioned them in Local environment path as well. If I download any Angular template from Github and Try to do NPM Install and it throws these error always. What shall I do to fix these error?

//        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 (D:\Interview\node_modules\which\which.js:13:12)
//        gyp verb `which` failed     at F (D:\Interview\node_modules\which\which.js:68:19)
//        gyp verb `which` failed     at E (D:\Interview\node_modules\which\which.js:80:29)
//        gyp verb `which` failed     at D:\Interview\node_modules\which\which.js:89:16
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\index.js:42:5
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\windows.js:36:5
//        gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21)
//        gyp verb `which` failed  python2 Error: not found: python2
//        gyp verb `which` failed     at getNotFoundError (D:\Interview\node_modules\which\which.js:13:12)
//        gyp verb `which` failed     at F (D:\Interview\node_modules\which\which.js:68:19)
//        gyp verb `which` failed     at E (D:\Interview\node_modules\which\which.js:80:29)
//        gyp verb `which` failed     at D:\Interview\node_modules\which\which.js:89:16
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\index.js:42:5
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\windows.js:36:5
//        gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21) {
//        gyp verb `which` failed   code: 'ENOENT'
//        gyp verb `which` failed }
//        gyp verb check python checking for Python executable "python" in the PATH
//        gyp verb `which` succeeded python C:\Program Files (x86)\Python38-32\python.EXE
//        gyp ERR! configure error 
//        gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python38-32\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: invalid syntax
//        gyp ERR! stack 
//        gyp ERR! stack     at ChildProcess.exithandler (node:child_process:333:12)
//        gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
//        gyp ERR! stack     at maybeClose (node:internal/child_process:1063:16)
//        gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
//        gyp ERR! System Windows_NT 10.0.18363
//        gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Interview\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
//        gyp ERR! cwd D:\Interview\node_modules\node-sass
//        gyp ERR! node -v v15.5.1
//        gyp ERR! node-gyp -v v3.8.0
//        gyp ERR! not ok
//        Build failed with error code: 1       
//        npm ERR! code ELIFECYCLE
//        npm ERR! errno 1
//        npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
//        npm ERR! Exit status 1
//        npm ERR!
//        npm ERR! Failed at the node-sass@4.14.1 postinstall script.
//        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  • As it says not found `python2` so seems like the library you are trying to install requires you to have `python` installed in your machine – sourav satyam Jan 22 '21 at 06:47
  • I have installed Python 3.8 should I still install py 2? –  Jan 22 '21 at 06:51
  • `gyp verb which failed python2 Error: not found: python2` so I think it require python2 – sourav satyam Jan 22 '21 at 06:52
  • Python3 is completely incompatible with Python2. A lot of Python2 scripts will not run on Python3. I know this is kind of a weird concept if you are a javascript programmer because you can take javascript written in 1998 and it would still probably work in modern browsers but most programming languages don't care about backwards compatibility. Javascript is the odd one out in this case. Not being able to run old code is actually normal – slebetman Jan 22 '21 at 08:56
  • Npm cache verify && npm install doesnt work? – Raz Ronen Jan 22 '21 at 11:13
  • I am getting this same error on a new M2 Mac. Everything I find is talking about windows. Very odd – AndrewLeonardi Aug 11 '22 at 14:13

1 Answers1

2

I think you are using Windows for development. Some node.js modules required to build locally on a machine. so, that why it needs python version 2.x and other tools.

windows-build-tools package install required tools to build module locally. Go ahead and install this package and after installing it then try again running the command npm install command

osama
  • 116
  • 1
  • 9
  • Any idea why this would be happening on a mac? – AndrewLeonardi Aug 11 '22 at 14:15
  • Not sure, But There might be a case if python is missing. If Python is available you can check if node version, to see if package you are installing support the node version. @AndrewLeonardi – osama Aug 12 '22 at 06:24
  • For me it was Node and ended up being a CPU issue due to a new Mac M2 https://stackoverflow.com/questions/73252661/npm-error-object-assignnew-errornot-found-cmd-code-enoent – AndrewLeonardi Aug 12 '22 at 14:26