Blog

Fix "No Xcode or CLT version detected" When Running npm install

Laravel

Introduction

In this tutorial, we will address a common issue that occurs when running npm install after setting up a new Laravel project. If you encounter the following error message, we will guide you through the steps to resolve it and successfully run npm install.

Error Message

When running npm install, the following error message is displayed:

sebastian@Sebastians-iMac my-project % npm install

> fsevents@1.2.11 install /Users/sebastian/Development/valet/my-project/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
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 1005 packages from 484 contributors and audited 17215 packages in 11.75s
found 0 vulnerabilities

Solution

Step 1: Remove Xcode Command Line Tools To resolve this issue, you need to remove the Xcode Command Line Tools. Follow these steps:

  1. Open the terminal.
  2. Execute the following command:
    sudo rm -r -f /Library/Developer/CommandLineTools
    

For detailed information, refer to the official documentation.

Step 2: Reinstall Xcode Command Line Tools After removing the Command Line Tools, you need to set them up again. Perform the following steps:

  1. Open the terminal.
  2. Run the command:
    xcode-select --install
    

Once you have completed these steps, proceed to the next section to verify the solution.

Verification

To confirm that the issue has been resolved, try running npm install again. It should now complete successfully without any error messages.

Conclusion

In this tutorial, we addressed the common error encountered when running npm install in a new Laravel project setup. By following the steps outlined here, you successfully resolved the issue by removing and reinstalling the Xcode Command Line Tools.