dotnet: command not found in Mac - macos

So I downloaded NET Core 2.1 SDK for mac and installed it. But when I run the dotnet command from terminal it throws -bash: dotnet: command not found error.
I am trying to use the dotnet new react to spin up a new .Net Core/React project.
How can I fix this? Thanks!

Make sure your macOS version meets the prerequisites
https://learn.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore2x
If it does, then after installing via the installer, in a new terminal run this command
ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/
Then try dotnet --version
hopefully that should work
EDIT:
You might need to add x64 like so:
ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/
Courtesy of Stan in the comments

For Mac M1
sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/
If you add symbolic link to /usr/local/bin/ but you get file exist error.
You can delete the dotnet file at /usr/local/bin/
or
at you finder Shift + ⌘ Command + G and type /usr/local/bin/ , delete the dotnet file in finder.
For M1 and M2, make sure you are installing the Arm64 version -
Marcelo Gonella

Just another way how to successfully install dotnet on a Mac: using Homebrew, you can simply run:
brew install dotnet
to have it install. Advantages include automatic updates via brew upgrade and less to worry about permissions or any of the workarounds mentioned as solutions before me.
You can find the formula information here: https://formulae.brew.sh/formula/dotnet
You also need to download & install Runtime from here

If you are using the dotnet x64 installer for mac which can be found here , use this command
sudo su
ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/

I solved by editing ~/.zshrc
#Add .NET to $PATH
export PATH="/usr/local/share/dotnet:$PATH"

Run sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/ in the command line, you then should be prompted for your password. This is the solution that worked for me on Mac OS Catalina.

.NET 6.x on MacOS I had to run with updated path
ln -s /usr/local/share/dotnet/**x64**/dotnet /usr/local/bin/
Run with sudo if you getting a permission error.

I solved it this way:
Add entry to .bash_profile
Before:
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/opt/gradle/gradle-4.10.2/bin
After:
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/opt/gradle/gradle-4.10.2/bin:/usr/local/share/dotnet

For Rider Users: If you are installed Rider and making development on it, dotnet must be installed on your machine.
For me, I can not found dotnet installation in specified locations; here or microsoft documentations. But Rider makes its own installation.
Go to Rider - Preferences - Buildy, execution, deploymend - Toolset and build and get the path of ".NET CLI executable path". This path specifies the path of sdk installation.
You can run the command below with location you found.
sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/

If you are using mac with M1 (arm) make sure you install the Arm64 version and not the x64 version that you download by default

Related

dotnet core 2.1.8 setup for OpenApi specification on Mac m1

I am trying to install dotnet core 2.1.8 for existing OpenAPI specification project.
But I'm getting this error
zsh: command not found: dotnet
I have also used sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/ but it didn't work for me.
I solve this by run this code in terminal
sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/
At first remove the dotnet file from /usr/local/bin/ and run the code in terminal
you can run dotnet --version to check version.
/usr/local/share/dotnet/x64/dotnet this path is not available in my mac m1.
to find out your path got to the dotnet folder right click on the dotnet application and press and hold option key in your keybord now you copy path.

error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance [duplicate]

Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, but active
developer directory '/Library/Developer/CommandLineTools' is a command
line tools instance
What is the problem?
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools when a full regular Xcode was required (happens when CommandLineTools are installed after Xcode)
Solution:
Install Xcode (get it from https://appstore.com/mac/apple/xcode) if you don't have it yet.
Accept the Terms and Conditions.
Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
Point xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
Xcode: /Applications/Xcode.app/Contents/Developer
Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer
Other solution for those who don't want to install Xcode:
Install Command Line Tools (if you haven't already):
xcode-select --install
Change the active directory:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This worked for me (git).
I was having an issue while trying to install packages using npm.
I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/"
To fix this
I opened Xcode.
Preferences
Locations
Selected the Command Lin Tools: Xcode 6.1.1
Now when installing packages with npm I no longer get errors.
Xcode > Preferences > Locations > Command Line Tools
Select the option matching your version of Xcode.
Simply run sudo xcode-select -r which should automatically reset the path.
-r, --reset
Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must be
run with superuser permissions (see sudo(8)), and will affect all users on the system.
I just ran the following command and the issue was resolved for me:
sudo xcode-select --reset
Type this in your terminal
xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
if you installed XCode already, All you have to do is to...
Open XCode
Go To Xcode > Preferences > Locations
From the Command Line Tools Select your XCode
Just in case you're using xcode beta:
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
I had to run this first
sudo xcode-select --reset
then
sudo xcode-select -switch /Library/Developer/CommandLineTools
and then it worked.
Download Xcode from App Store.
Go to Xcode preferences/Locations/CommandlineTools
You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'
I was having the same problem in high sierra.
running the following command solved it
npm explore npm -g -- npm install node-gyp#latest
Please follow the steps below :
The latest version of Xcode can be downloaded from https://developer.apple.com/xcode/download/
It will be downloaded in the 'Downloads' unless specified otherwise. Please make sure to check the path where you have downloaded and extracted the Xcode
Now unlike other downloaded applications, on extraction, Xcode doesn't give the option to move it to Applications
Note the XCODE-ACTUAL-LOCATION or move it to the Applications
Note if you have downloaded Xcode or Xcode-beta
Based on 4 and 5, execute one of the commands (Do not execute all of them without reading above description):
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer
Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuild and accept the language. After this npm install bcrypt worked like a charm!
Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect
#!/bin/bash
exit 0
chmod +x /usr/local/bin/xcodebuild
Simple reinstall xcode-select
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
In case you are using Xcode beta, run
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer
instead of
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
I was able to solve this error without installing the full Xcode application. You must, however, have xcode command line tools installed.
From here:
$ cd /usr/bin
$ sudo mv xcodebuild xcodebuild.orig (A backup just in case)
$ vim xcodebuild
Paste the following:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $#
fi
$ sudo chmod +x xcodebuild
XCode2:
sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer
Pay attention to the "\" to escape the space
I had two instance of Xcode installed xcode.app and xcode-beta.app
When I tried to create a build with netbeans it showed me the error
"supported version of xcode and command line tools not found netbeans"
I followed the following steps:
"xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
"xcodebuild -version" starts with "Xcode"
after 1 I found that it is pointing me to xcode-beta.app
so here is the solution which worked like a charm:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
For context, today is Jan 28, 2019.
On my Mac, I did two things to resolve this problem:
Run the following command in your terminal:
sudo xcode-select --install
Restart your Mac.
Until I restarted the computer, the problem kept occurring in my Android Studio. After reboot, it was working just fine. Also note that I did not execute any --switch commands as others are doing. I hope this helps.
Manually installing Command LineTool worked for me.
I stalled xcode through App Store
Still could not download Homebrew
I installed Command Line Tool manually through link.
Bing Bang Boom
https://developer.apple.com/download/more/?=command%20line%20tools
sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
because my Xcode name in Application is "Xcode 10",
sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
works.
In my case,
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
didn't work because my Xcode had some special name. eg) Xcode_11.2.0_beta_2_stackoverflow.app
cd /applications
ls
Then I found my Xcode name, then replace it with
sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer
It worked for me.
None of the above worked for me. I originally installed Command Line Tools separately, and then all of Xcode. What worked for me was to uninstall Command Line Tools as shown here. Then, when trying to run xcode-select again, I was asked to reinstall them.
*By the way, the very reason why I found this thread was because I had installed some libraries (particularly gcc) with macports, presumably using the old Command Line Tools, and then I installed the full Xcode midway into development. So anyways, for my case, I had to reinstall macports after removing the stand-alone Command Line Tools, reinstalling them, reinstalling gcc, and then my compilation worked.
There are only two steps required, and the full XCode.app is not required at all:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
At this point the "Installing Softwre" dialog pops up:
That's it!
None of the above solutions helped me. I was working on an old project, and I had the latest version of NodeJs installed globally (v14.x) on my computer.
No node version above 10.1.x worked for me and when testing I received the same error as above.
Solution
I installed "n" which is a nodeJs version manager like nvm
I downgraded my nodeJs version to 9.x
npm install now works.
I will now need to update my versions, or Specify my node version in my package.json.
The simple fix that worked for me is drag and drop Xcode.app from the current location (In my case it was in downloads) to Applications.

Mac command line tools 11.4 no longer has svn

I just updated XCode and the command line tools to 11.4. Now when I run svn it says "svn: error: The subversion command line tools are no longer provided by Xcode". The release notes say "Command line tool support for Subversion — including svn, git-svn, and related commands is no longer provided by Xcode. If you need Subversion or related command line tools the you need to install the Command Line Tools package by running xcode-select --install." I seem to be in a loop here, as the tools are installed. Has anyone experienced this problem and resolved it?
macOS Catalina
I had the same issue after upgrading to Catalina 10.15. It's clearly mentioned in the Apple website that SVN is deprecated in Xcode 11:
You can find it here: https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes
Command line tool support for Subversion — including svn, git-svn, and related commands — is no longer provided by Xcode.
The solution is to install the standalone Command Line Tools package instead:
sudo rm -rf /Library/Developer/CommandLineTools
followed by:
sudo xcode-select --install
This will replace the bundled Command Line Tools with the standalone package.
If it doesn't work for you then try to install it with brew.
brew install svn
brew is a package manager for MacOS so if you don't have it installed then you can simply install it: https://brew.sh/
macOS Big Sur
I faced the same issue Today (16th November 2020) after upgrading to MacOS Big Sur. I was able to fix it by installing the SVN again using brew install svn command.
If you faced permission errors after running above command, you can fix it by running following command.
sudo chown -R $(whoami) /usr/local/*
brew install svn
in Xcode 11.4. Svn has been removed.
I had same issue from Netbeans and have done the following from command line and now all fine
sudo xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install svn
Coming from a FreeBSD background we elected to install SVN via MacPorts which is akin to FreeBSD Ports. So basically one would first need to install MacPorts and then install SVN as follows:
sudo port install subversion
Some details -
Install MacPorts: https://www.macports.org/install.php
Install SVN: https://trac.macports.org/wiki/howto/Subversion
It took less than five(5) minutes and works well for us.
I switched to SVNKIT which works very well for my purposes. Since I'm doing a lot of Java development is no drawback for me that SVNKIT is based on Java.
The big advantage is that SVNKIT will still work even if Apple throws SVN out completely.
I found svn still available on my Mac (upgraded from 10.15.x -> Big Sur, including XCode upgrade) in
/Library/Developer/CommandLineTools/usr/bin/svn
In the Apple Developers forum I read the suggestion to make an alias, which worked for me. However, considering svn is being dropped by Apple, this will probably not work on new installs, but it could be useful for those of us that just want it to work for now after upgrading.
alias svn=/Library/Developer/CommandLineTools/usr/bin/svn
Note: I found it easier to just make a symbolic link to svn:
ln -s /Library/Developer/CommandLineTools/usr/bin/svn /usr/local/bin/svn
my mac os version is macOs Catalina 10.15.5,I try
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
brew install svn
but it not work.so I try to install with source code.It's work!
tar xvf subversion-1.14.0.tar.gz
cd subversion-1.14.0
./configure --with-apr=/usr/local/opt/apr --with-apr-util=/usr/local/opt/apr-util
make
now,you can find it in /usr/local/bin/
Based partly on the other answers here, I built from source with this procedure:
Download & unpack svn source tarball (NOT zip file!) from
https://subversion.apache.org/download.cgi
cd subversion-1.14.0
./get-deps (this seems to have downloaded apr and apr-util but not
built them)
cd apr
sudo mkdir /usr/local/opt
(because I did not already have such a directory on a fresh Mac)
./configure --prefix=/usr/local/opt/apr
make
make test
(saw lots of "OK" and "SUCCESS", plus one failure in "testsock")
sudo make install
cd ../apr-util
./configure --prefix=/usr/local/opt/apr-util --with-apr=/usr/local/opt/apr
cd ..
make
./configure --with-apr=/usr/local/opt/apr --with-apr-util=/usr/local/opt/apr-util --with-lz4=internal --with-utf8proc=internal
make
sudo make install
The top instructions (removing the command line tools, xcode-select --install, and brew install svn) worked for me (Monterey, 12.5.1, on an M1 pro). Thanks!
However, after I did the brew install, I had to manually remove the old svn version from /opt/local/bin before the new version would run. (discovered with $ which svn). Might be the result of migrating from the old laptop to the new one.

Errors during make test installing kibana via homebrew on Mac (xcode issue?) [duplicate]

Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, but active
developer directory '/Library/Developer/CommandLineTools' is a command
line tools instance
What is the problem?
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools when a full regular Xcode was required (happens when CommandLineTools are installed after Xcode)
Solution:
Install Xcode (get it from https://appstore.com/mac/apple/xcode) if you don't have it yet.
Accept the Terms and Conditions.
Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
Point xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
Xcode: /Applications/Xcode.app/Contents/Developer
Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer
I was having an issue while trying to install packages using npm.
I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/"
To fix this
I opened Xcode.
Preferences
Locations
Selected the Command Lin Tools: Xcode 6.1.1
Now when installing packages with npm I no longer get errors.
Other solution for those who don't want to install Xcode:
Install Command Line Tools (if you haven't already):
xcode-select --install
Change the active directory:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This worked for me (git).
Xcode > Preferences > Locations > Command Line Tools
Select the option matching your version of Xcode.
Simply run sudo xcode-select -r which should automatically reset the path.
-r, --reset
Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must be
run with superuser permissions (see sudo(8)), and will affect all users on the system.
I just ran the following command and the issue was resolved for me:
sudo xcode-select --reset
Type this in your terminal
xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
if you installed XCode already, All you have to do is to...
Open XCode
Go To Xcode > Preferences > Locations
From the Command Line Tools Select your XCode
Just in case you're using xcode beta:
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
I had to run this first
sudo xcode-select --reset
then
sudo xcode-select -switch /Library/Developer/CommandLineTools
and then it worked.
Download Xcode from App Store.
Go to Xcode preferences/Locations/CommandlineTools
You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'
I was having the same problem in high sierra.
running the following command solved it
npm explore npm -g -- npm install node-gyp#latest
Please follow the steps below :
The latest version of Xcode can be downloaded from https://developer.apple.com/xcode/download/
It will be downloaded in the 'Downloads' unless specified otherwise. Please make sure to check the path where you have downloaded and extracted the Xcode
Now unlike other downloaded applications, on extraction, Xcode doesn't give the option to move it to Applications
Note the XCODE-ACTUAL-LOCATION or move it to the Applications
Note if you have downloaded Xcode or Xcode-beta
Based on 4 and 5, execute one of the commands (Do not execute all of them without reading above description):
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer
Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuild and accept the language. After this npm install bcrypt worked like a charm!
Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect
#!/bin/bash
exit 0
chmod +x /usr/local/bin/xcodebuild
Simple reinstall xcode-select
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
In case you are using Xcode beta, run
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer
instead of
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
I was able to solve this error without installing the full Xcode application. You must, however, have xcode command line tools installed.
From here:
$ cd /usr/bin
$ sudo mv xcodebuild xcodebuild.orig (A backup just in case)
$ vim xcodebuild
Paste the following:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $#
fi
$ sudo chmod +x xcodebuild
XCode2:
sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer
Pay attention to the "\" to escape the space
I had two instance of Xcode installed xcode.app and xcode-beta.app
When I tried to create a build with netbeans it showed me the error
"supported version of xcode and command line tools not found netbeans"
I followed the following steps:
"xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
"xcodebuild -version" starts with "Xcode"
after 1 I found that it is pointing me to xcode-beta.app
so here is the solution which worked like a charm:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
For context, today is Jan 28, 2019.
On my Mac, I did two things to resolve this problem:
Run the following command in your terminal:
sudo xcode-select --install
Restart your Mac.
Until I restarted the computer, the problem kept occurring in my Android Studio. After reboot, it was working just fine. Also note that I did not execute any --switch commands as others are doing. I hope this helps.
Manually installing Command LineTool worked for me.
I stalled xcode through App Store
Still could not download Homebrew
I installed Command Line Tool manually through link.
Bing Bang Boom
https://developer.apple.com/download/more/?=command%20line%20tools
sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
because my Xcode name in Application is "Xcode 10",
sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
works.
In my case,
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
didn't work because my Xcode had some special name. eg) Xcode_11.2.0_beta_2_stackoverflow.app
cd /applications
ls
Then I found my Xcode name, then replace it with
sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer
It worked for me.
None of the above worked for me. I originally installed Command Line Tools separately, and then all of Xcode. What worked for me was to uninstall Command Line Tools as shown here. Then, when trying to run xcode-select again, I was asked to reinstall them.
*By the way, the very reason why I found this thread was because I had installed some libraries (particularly gcc) with macports, presumably using the old Command Line Tools, and then I installed the full Xcode midway into development. So anyways, for my case, I had to reinstall macports after removing the stand-alone Command Line Tools, reinstalling them, reinstalling gcc, and then my compilation worked.
There are only two steps required, and the full XCode.app is not required at all:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
At this point the "Installing Softwre" dialog pops up:
That's it!
None of the above solutions helped me. I was working on an old project, and I had the latest version of NodeJs installed globally (v14.x) on my computer.
No node version above 10.1.x worked for me and when testing I received the same error as above.
Solution
I installed "n" which is a nodeJs version manager like nvm
I downgraded my nodeJs version to 9.x
npm install now works.
I will now need to update my versions, or Specify my node version in my package.json.
The simple fix that worked for me is drag and drop Xcode.app from the current location (In my case it was in downloads) to Applications.

Xcode 6.1 - How to uninstall command line tools?

I installed Xcode command line tool by issuing xcode-select --install; now I want to uninstall it (without uninstalling Xcode).
I've tried
sudo /Developer/Library/uninstall-devtools --mode=all
but then I get the error
sudo: /Developer/Library/uninstall-devtools: command not found
If you installed the command line tools separately, delete them using:
sudo rm -rf /Library/Developer/CommandLineTools
An excerpt from an apple technical note (Thanks to matthias-bauch)
Xcode includes all your command-line tools. If it is installed on your
system, remove it to uninstall your tools.
If your tools were downloaded separately from Xcode, then they are
located at /Library/Developer/CommandLineTools on your system. Delete
the CommandLineTools folder to uninstall them.
you could easily delete using terminal:
Here is an article that explains how to remove the command line tools but do it at your own risk.Try this only if any of the above doesn't work.
You can simply delete this folder
/Library/Developer/CommandLineTools
Please note: This is the root /Library, not user's ~/Library).

Resources