15

Whenever I run my code I always get the same error. I uninstall node and npm and reinstall. But now there is no "node_modules" and I get the same error. How can I fix it?

npm ERR! code 1
npm ERR! path /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/local/bin/node',
npm ERR! gyp verb cli   '/Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.14.2 | darwin | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python /Users/bng/opt/anaconda3/bin/python
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Command failed: /Users/bng/opt/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack 
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:399:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bng/.npm/_logs/2022-03-24T08_05_44_961Z-debug-0.log

There isn't node-sass and node-gyp. When I tried to install them I also got the same error. I cannot install anything.

su-wan Kenobi
  • 223
  • 1
  • 4
  • 10
  • What does `which -a python2` show when you execute it in your terminal? – t.niese Mar 24 '22 at 08:24
  • nothing comes out ``` (base) MacBook-Pro:12-vue-spa bng$ which -a python2 (base) MacBook-Pro:12-vue-spa bng$ ``` – su-wan Kenobi Mar 24 '22 at 08:47
  • Ok so it looks like python2 is not installed or cannot be found, but whatever you want to install expects python2 to be installed. So you have to install it using e.g. brew. – t.niese Mar 24 '22 at 09:02
  • Does this answer your question? [Yarn install throws error: gyp verb \`which\` failed Error: not found: python2](https://stackoverflow.com/questions/61744726/yarn-install-throws-error-gyp-verb-which-failed-error-not-found-python2) – Anton Strogonoff Mar 24 '22 at 09:13

8 Answers8

21

I solved this problem by changing the node version to 14.15.1

Ali Yazdanifar
  • 372
  • 4
  • 12
  • 2
    In above comments, It is mentionded node 14 works, [you can downgrade 14 from here](https://stackoverflow.com/questions/47008159/how-to-downgrade-node-version#answer-61491579) – Ucdemir Oct 01 '22 at 10:11
  • 3
    I tried node 18.x but i get the error. downgrading to 14.15.5 solved the issue for me. Ahsant Hamvatan. – afruzan Oct 06 '22 at 09:15
  • 1
    NOTE: DOWNGRADING is not a good option! It's like suggesting to go with old version of software that is end of life. Please UPVOTE the answer with yarn remove node-sass yarn add sass. Don't compromise security of your program. – Lucas S. Jul 27 '23 at 13:23
9

Do not use node-sass anymore. Remove 'node-sass' in package.json. pls use 'dart-sass'.

https://www.npmjs.com/package/dart-sass (dart-sass is default now)


update answer at 2023/08/24

the answer still stand. we can see node-sass -> dart-sass -> sass.

now pls use sass https://www.npmjs.com/package/sass

Yang
  • 189
  • 5
  • 1
    Indeed! Removing `node-sass` from package.json made `npm install` finish successfully, finally! – М.Б. Nov 12 '22 at 14:13
  • 1
    Also see: https://stackoverflow.com/a/73312114/6118794 – М.Б. Nov 12 '22 at 14:16
  • 'https://www.npmjs.com/package/dart-sass' says: "This package has been deprecated. Author message: This package has been renamed to 'sass'." – wbartussek May 11 '23 at 09:30
5

Please don't waste your time running the suggested command by others. Please uninstall node.js and use the Node v14.x. It will solve it automatically.

2

With most of the operating systems removing python2 this is a common issue for most projects. It definitely affected 4/5 of my recent projects after upgrading to current Linux/Debian Stable which removed python2.

The solution is for system to start using python3 and in order to do that you need to..

Solution/Solved is:

node-sass is actually at fault. Python2 is required until version 6.0.0. Normally you would upgrade to latest 7.0.3 but node-sass is currently obsolete, so we will swap to sass project.

yarn remove node-sass
yarn add sass

I've given more details on reasoning why here, or alternative dart-sass if you use "render() and renderSync() functions".:

Solved-ERR!gyp-info-using-node-gyp-3.8.0-gyp-verb-which-failed-Error-not-found-python2

Affected:

  • node.js /react web apps
  • Elixir/Phoenix assets
  • Android apps
  • Vue.js projects
Lucas S.
  • 77
  • 6
1

I got the same error and did this:

 1. npm install node-sass
 2. npm install  
 3. npm ci
 4. ng serve --open (to launch the project ).
Skatox
  • 4,237
  • 12
  • 42
  • 47
0

The following solution works for me.

Try:

npm cache clean --force

npm uninstall node-sass

Uninstall node modules from your project

npm i sass --save
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Farooq
  • 19
  • 3
0

Please uninstall the nodejs and reinstall the node version 14.21.3

https://nodejs.org/download/release/v14.21.3/

-1

!important

i run into the same issue. ANd What I recomend to you is to install nvm to control your node version instead of unistalling the current version causing other problems with the existent projects.

NVM Installation Guide

https://www.geeksforgeeks.org/how-to-install-and-use-nvm-on-windows/

or

https://tecadmin.net/install-nvm-macos-with-homebrew/

After installation

After you are sure that you'd installed nvm successfully you can do:

  1. nvm --version to check if nvm is successfully installed
  2. nvm install [desired node version] ex.: nvm install 14.0.0
  3. nvm list to check all node versions installed
  4. nvm use [desired version] to change between node version ex.: nvm use 14.0.0

Conclusion

As I mention above, instead of unistalling your node versions you can install different versions of node and changing between then avoid future errors.

Be Happy even with bugs