'nuget' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# Table of Contents

  1. 'nuget' is not recognized as an internal or external command
  2. Resolve the error on Windows
  3. Resolve the error on macOS or Linux

# 'nuget' is not recognized as an internal or external command

The error "'nuget' is not recognized as an internal or external command, operable program or batch file" occurs for two main reasons:

  1. Not having nuget installed on your machine.
  2. Not having nuget in your system's PATH environment variable.

nuget is not recognized as internal or external command

shell
'nuget' is not recognized as an internal or external command, operable program or batch file The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program

# Resolve the error on Windows

To resolve the error on Windows:

  1. Open the nuget downloads page and download the nuget.exe file.

download nuget exe file

  1. The nuget.exe file isn't executable, so don't run it. Instead, open the directory where you downloaded the file.

  2. Right-click on the nuget.exe file and click on "Properties".

right click properties

  1. Copy the location of the directory that contains nuget.exe. Note that we need the location of the directory where nuget.exe is located, not the location of the nuget.exe file itself.

copy nuget exe location

Now you have to add the path you just copied to your PATH environment variable:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. Click on "New" and then paste the path.

click new and paste path

  1. Click "OK" twice to confirm.

  2. Close your Command prompt application and then reopen it.

Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

Open a new CMD shell and run the nuget command to verify nuget is installed and configured properly.

shell
nuget

verify nuget installed

# Resolve the error on macOS or Linux

You can resolve the "command not found: nuget" error by following the instructions in this section of the docs.

  1. Install Mono for your operating system.

  2. Run the following command in your terminal.

shell
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
  1. Create an alias to the nuget command by adding the following line to your configuration file (e.g. ~/.bash_profile, ~/.bash_aliases or ~/.bashrc).
bash
# Create an alias for `nuget` alias nuget="mono /usr/local/bin/nuget.exe"
  1. Restart your shell and use the nuget command to verify nuget is installed and configured properly.
shell
nuget

If you get the "command not found: mono" error, you have to install Mono for your operating system as it is a prerequisite for nuget.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.