npm install with error: `gyp` failed with exit code: 1

Solution 1:

If this is a mac machine (OSX) here is what you can do

use terminal

xcode-select --print-path

then remove installed version

sudo rm -r -f /Library/Developer/CommandLineTools

and reinstall

xcode-select --install

that should fix the problem

Ref: gyp: No Xcode or CLT version detected macOS Catalina

Solution 2:

this works for me. run command below one by one

rm -rf node_modules
rm package-lock.json
npm update
npm install