title: npm install fails with 'git dep preparation failed' and 'checking for python executable error'
body: <p>my version</p>
  <ul>
  <li>node version : 14.19.3</li>
  <li>npm version : 7.6.0</li>
  <li>os : macOS Monterey 12.3.1 , M1 chip</li>
  </ul>
  <h3>Problem</h3>
  <p>While running <code>npm install</code> with <code>package.json</code>, it keep fails with several errors.<br />
  What's even stranger is that there was no problem few hours ago.</p>
  <p>Here are my errors<br /></p>
  <p><strong>1) <code>npm install</code></strong><br />
  fails with unable to resolve dependency tree</p>
  <p><a href="https://i.stack.imgur.com/UyP8Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UyP8Q.png" alt="enter image description here" /></a></p>
  <p>It suggests me to command with <code>--legacy-peer-deps</code></p>
  <p><strong>2) <code>npm install --legacy-peer-deps</code></strong><br />
  fails with <code>git dep preparation failed</code> and python error</p>
  <pre class="lang-sh prettyprint-override"><code>9622 verbose stack Error: git dep preparation failed
  9622 verbose stack     at ChildProcess.&lt;anonymous&gt; (/Users/myname/.nvm/versions/node/v14.19.3/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
  9622 verbose stack     at ChildProcess.emit (events.js:400:28)
  9622 verbose stack     at maybeClose (internal/child_process.js:1088:16)
  9622 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
  9623 verbose cwd /Users/myname/Desktop/inpock/link-client
  9624 verbose Darwin 21.4.0
  9625 verbose argv &quot;/Users/myname/.nvm/versions/node/v14.19.3/bin/node&quot; &quot;/Users/myname/.nvm/versions/node/v14.19.3/bin/npm&quot; &quot;install&quot; &quot;--legacy-peer-deps&quot;
  9626 verbose node v14.19.3
  9627 verbose npm  v7.6.0
  9628 error code 1
  9629 error git dep preparation failed
  9630 error command /Users/myname/.nvm/versions/node/v14.19.3/bin/node /Users/myname/.nvm/versions/node/v14.19.3/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/myname/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
  9631 error npm WARN using --force Recommended protections disabled.
  9631 error npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
  9631 error npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
  9631 error npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
  9631 error npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
  9631 error npm WARN deprecated har-validator@5.1.5: this library is no longer supported
  9631 error npm WARN deprecated eslint-loader@2.2.1: This loader has been deprecated. Please use eslint-webpack-plugin
  9631 error npm WARN deprecated fsevents@2.1.3: &quot;Please update to latest v2.3 or v2.2&quot;
  9631 error npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
  9631 error npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
  9631 error npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
  9631 error npm WARN deprecated source-map-url@0.4.0: See https://github.com/lydell/source-map-url#deprecated
  9631 error npm WARN deprecated debug@3.2.6: Debug versions &gt;=3.2.0 &lt;3.2.7 || &gt;=4 &lt;4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
  9631 error npm WARN deprecated debug@3.2.6: Debug versions &gt;=3.2.0 &lt;3.2.7 || &gt;=4 &lt;4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
  9631 error npm WARN deprecated debug@3.2.6: Debug versions &gt;=3.2.0 &lt;3.2.7 || &gt;=4 &lt;4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
  9631 error npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
  9631 error npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
  9631 error npm WARN deprecated debug@4.1.1: Debug versions &gt;=3.2.0 &lt;3.2.7 || &gt;=4 &lt;4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
  9631 error npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
  9631 error npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported
  9631 error npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
  9631 error npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
  9631 error npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  9631 error npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
  9631 error npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  9631 error npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
  9631 error npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
  9631 error npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
  9631 error npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
  9631 error npm WARN deprecated highlight.js@9.18.3: Version no longer supported. Upgrade to @latest
  9631 error npm WARN deprecated core-js@2.6.11: core-js@&lt;3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
  9631 error npm ERR! code 1
  9631 error npm ERR! path /Users/myname/.npm/_cacache/tmp/git-clone-b491e267/node_modules/node-sass
  9631 error npm ERR! command failed
  9631 error npm ERR! command sh -c node scripts/build.js
  9631 error npm ERR! Building: /Users/myname/.nvm/versions/node/v14.19.3/bin/node /Users/myname/.npm/_cacache/tmp/git-clone-b491e267/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
  9631 error npm ERR! gyp info it worked if it ends with ok
  9631 error npm ERR! gyp verb cli [
  9631 error npm ERR! gyp verb cli   '/Users/myname/.nvm/versions/node/v14.19.3/bin/node',
  9631 error npm ERR! gyp verb cli   '/Users/myname/.npm/_cacache/tmp/git-clone-b491e267/node_modules/node-gyp/bin/node-gyp.js',
  9631 error npm ERR! gyp verb cli   'rebuild',
  9631 error npm ERR! gyp verb cli   '--verbose',
  9631 error npm ERR! gyp verb cli   '--libsass_ext=',
  9631 error npm ERR! gyp verb cli   '--libsass_cflags=',
  9631 error npm ERR! gyp verb cli   '--libsass_ldflags=',
  9631 error npm ERR! gyp verb cli   '--libsass_library='
  9631 error npm ERR! gyp verb cli ]
  9631 error npm ERR! gyp info using node-gyp@3.8.0
  9631 error npm ERR! gyp info using node@14.19.3 | darwin | x64
  9631 error npm ERR! gyp verb command rebuild []
  9631 error npm ERR! gyp verb command clean []
  9631 error npm ERR! gyp verb clean removing &quot;build&quot; directory
  9631 error npm ERR! gyp verb command configure []
  9631 error npm ERR! gyp verb check python checking for Python executable &quot;/Users/myname/.pyenv/shims/python&quot; in the PATH
  9631 error npm ERR! gyp verb `which` succeeded /Users/myname/.pyenv/shims/python /Users/myname/.pyenv/shims/python
  9631 error npm ERR! gyp ERR! configure error
  9631 error npm ERR! gyp ERR! stack Error: Command failed: /Users/myname/.pyenv/shims/python -c import sys; print &quot;%s.%s.%s&quot; % sys.version_info[:3];
  9631 error npm ERR! gyp ERR! stack   File &quot;&lt;string&gt;&quot;, line 1
  9631 error npm ERR! gyp ERR! stack     import sys; print &quot;%s.%s.%s&quot; % sys.version_info[:3];
  9631 error npm ERR! gyp ERR! stack                       ^
  9631 error npm ERR! gyp ERR! stack SyntaxError: invalid syntax
  9631 error npm ERR! gyp ERR! stack
  9631 error npm ERR! gyp ERR! stack     at ChildProcess.exithandler (child_process.js:383:12)
  9631 error npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
  9631 error npm ERR! gyp ERR! stack     at maybeClose (internal/child_process.js:1088:16)
  9631 error npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
  9631 error npm ERR! gyp ERR! System Darwin 21.4.0
  9631 error npm ERR! gyp ERR! command &quot;/Users/myname/.nvm/versions/node/v14.19.3/bin/node&quot; &quot;/Users/myname/.npm/_cacache/tmp/git-clone-b491e267/node_modules/node-gyp/bin/node-gyp.js&quot; &quot;rebuild&quot; &quot;--verbose&quot; &quot;--libsass_ext=&quot; &quot;--libsass_cflags=&quot; &quot;--libsass_ldflags=&quot; &quot;--libsass_library=&quot;
  9631 error npm ERR! gyp ERR! cwd /Users/myname/.npm/_cacache/tmp/git-clone-b491e267/node_modules/node-sass
  9631 error npm ERR! gyp ERR! node -v v14.19.3
  9631 error npm ERR! gyp ERR! node-gyp -v v3.8.0
  9631 error npm ERR! gyp ERR! not ok
  9631 error npm ERR! Build failed with error code: 1
  9631 error
  9631 error npm ERR! A complete log of this run can be found in:
  9631 error npm ERR!     /Users/myname/.npm/_logs/2022-05-18T11_19_20_178Z-debug.log
  9632 verbose exit 1
  </code></pre>
  <h3>What I have tried</h3>
  <p>I've tried many other solutions. clean cache and install doesn't work...<br />
  I think my python variable or some package has messed up<br />
  Here is my zshrc file so please check and any help would be appreciated!</p>
  <p><strong>zshrc</strong></p>
  <pre class="lang-sh prettyprint-override"><code>export PATH=$HOME/bin:/opt/homebrew/bin:/usr/local/bin:$PATH
  export PATH=/usr/local/bin:$PATH # git version
  export PATH=$HOME/.pyenv/shims:$PATH
  
  # python
  # alias python=/usr/bin/python3
  # alias pip=/usr/bin/pip3
  # alias python=/usr/local/bin/python3
  # alias pip=/usr/local/bin/pip3
  alias python=&quot;python3&quot;
  
  
  # nvm
  export NVM_DIR=&quot;$HOME/.nvm&quot;
  [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; . &quot;$NVM_DIR/nvm.sh&quot; # This loads nvm
  
  # pyenv
  export PYENV_PATH=$HOME/.pyenv
  if which pyenv &gt; /dev/null; then eval &quot;$(pyenv init --path)&quot;; fi
  if which pyenv-virtualenv-init &gt; /dev/null; then eval &quot;$(pyenv virtualenv-init -)&quot;; fi
  eval &quot;$(/opt/homebrew/bin/brew shellenv)&quot;
  
  export NVM_DIR=&quot;$HOME/.nvm&quot;
  [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; \. &quot;$NVM_DIR/nvm.sh&quot;  # This loads nvm
  [ -s &quot;$NVM_DIR/bash_completion&quot; ] &amp;&amp; \. &quot;$NVM_DIR/bash_completion&quot;  # This loads nvm bash_completion
  
  ...
  </code></pre>
  <p>and this is what <code>which python</code> shows to me</p>
  <pre class="lang-sh prettyprint-override"><code>python: aliased to python3
  </code></pre>