Recently, when attempting to install the
gulp package using the
npm CLI (“Node package manager”, “Command line interface”) in the Terminal app, I saw an error message saying that
node-gyp rebuild is failed because
no Xcode or CLT version detected. In this tutorial, you’ll learn how to solve this problem.
What causes this error
In my case, the below error appeared when attempting to install the
gulp package using the
npm CLI (“Node package manager”, “Command line interface”) in the Terminal app.
$ npm install -g gulp /usr/local/bin/gulp -> /usr/local/lib/node_modules/gulp/bin/gulp.js > email@example.com install /usr/local/lib/node_modules/gulp/node_modules/fsevents > node-gyp rebuild No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'. No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'. No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'. gyp: No Xcode or CLT version detected! gyp ERR! configure error gyp ERR! stack Error: \`gyp\` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16) gyp ERR! stack at ChildProcess.emit (events.js:321:20) gyp ERR! stack at Process.ChildProcess.\_handle.onexit (internal/child_process.js:275:12) gyp ERR! System Darwin 19.3.0 gyp ERR! command "/usr/local/Cellar/node/13.8.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/lib/node_modules/gulp/node_modules/fsevents gyp ERR! node -v v13.8.0 gyp ERR! node-gyp -v v5.0.7 gyp ERR! not ok npm WARN optional SKIPPING OPTIONAL DEPENDENCY: firstname.lastname@example.org (node_modules/gulp/node_modules/fsevents): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: email@example.com install: \`node-gyp rebuild\` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 + firstname.lastname@example.org added 316 packages from 217 contributors in 65.799s
The error message above is self explanatory. It saying that the
node-gyp rebuild is failed, and this is because
No Xcode or CLT version detected.
- Xcode is an integrated development environment (IDE) for macOS containing a suite of software development tools developed by Apple for developing software for macOS, iPadOS, iOS, watchOS, and tvOS.
- The CLT stands for “Command Line Tools for Xcode”. This package enables UNIX-style development via Terminal by installing command line developer tools, as well as macOS SDK frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these tools are also embedded within the Xcode IDE.
This is strange because I am sure that the “Command Line Tools for Xcode” is installed on my Mac; I already used these tools, and before everything was fine. In my case, this error appeared after upgrading macOS to version 10.15 called “Catalina”. Therefore I thought that maybe there is some kind of problem with paths in my “Command Line Tools for Xcode” installation after upgrading macOS to Catalina, and I just need to reinstall the “Command Line Tools for Xcode” on my Mac to solve the problem.
Now we know what caused this error.
How to solve it
Once we know what is causing the
node-gyp rebuild to fail, we can use it to solve the problem. It is a really easy process. To solve this problem, we need to manually download and install the macOS “Command Line Tools for Xcode”. Now, step by step guide.
We can get macOS “Command Line Tools for Xcode” from the Developer section of the Apple website. For this, just browse to the developer.apple.com page, find the latest version of the “Command Line Tools for Xcode” and download it to your computer.
Note! At the time of this writing, the latest version of the “Command Line Tools for Xcode” is 11.3.1.
macOS “Command Line Tools for Xcode” (im my case version is 11.3.1) download directly to our Downloads folder as an DMG image file named
- A DMG file is a mountable disk image used to distribute software to the macOS operating system. Today, software developers typically build and distribute applications for macOS as DMG. In other words, DMG files are containers for apps in macOS.
Now we can install the “Command Line Tools for Xcode” using the file downloaded in the previous step. For this, just double-click on the
Command_Line_Tools_for_Xcode_11.3.1.dmg file to mount it, then double-click on the
Command_Line_Tools.pkg file in the window that opens to launch the installation wizard, and follow the installation wizard instructions.
Finally, we can try to install a package and verify that it installs without the
node-gyp rebuild error.
Type the following command and press the
Enter key to install a package (in this example
gulp will be installed).
npm install -g gulp
Let the command line do its work and don’t interrupt it until you see the final line that says about how many packages were added and updated. This can take a while, so be patient.
/usr/local/bin/gulp -> /usr/local/lib/node_modules/gulp/bin/gulp.js > email@example.com install /usr/local/lib/node_modules/gulp/node_modules/fsevents > node-gyp rebuild SOLINK_MODULE(target) Release/.node CXX(target) Release/obj.target/fse/fsevents.o SOLINK_MODULE(target) Release/fse.node + firstname.lastname@example.org added 71 packages from 33 contributors and updated 1 package in 21.56s
No errors. It works!
That’s it, you’re done. Now the
npm should install a packages without the
node-gyp rebuild error. So simple isn’t it?
If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!
I hope this article has helped you learn how to fix the
node-gyp rebuild error. If this article has helped you then please leave a comment
Thanks for reading!