free geoip
6

Dart Not Recognized as Internal or External Command

If you are working with Flutter or Dart on Windows, you might have faced the common error: “Dart is not…

If you are working with Flutter or Dart on Windows, you might have faced the common error: “Dart is not recognized as an internal or external command”. This issue usually happens when Dart SDK is not properly installed, or the PATH environment variable is not set correctly. In this article, we will explain the causes of this problem, provide step-by-step solutions, and show real examples of fixing the error in a Windows environment.

Dart Not Recognized as Internal or External Command

What Causes the Error?

The error occurs when the command prompt (CMD), PowerShell, or terminal cannot find the Dart executable. The reasons include:

  • Dart SDK is not installed on your computer.
  • The PATH environment variable does not include the Dart bin directory.
  • Flutter SDK was installed but Dart SDK path was not added to the system PATH.
  • Incorrect installation or corrupted files.

How to Check if Dart is Installed

Before fixing, you should verify whether Dart is installed on your system. Open your command prompt and type:

dart --version

If Dart is installed correctly, you should see output similar to:

Dart SDK version: 3.3.0 (stable) (Tue Feb 13 16:48:12 2024 +0100) on "windows_x64"

If instead you see the error “Dart is not recognized as an internal or external command”, then your PATH is not configured or Dart is missing.

Solution 1: Install Dart SDK

If you do not have Dart installed, you need to download and install it manually. Follow these steps:

  1. Go to the official Dart SDK download page: https://dart.dev/get-dart
  2. Download the Windows x64 zip file.
  3. Extract the file to a safe location, for example: C:\tools\dart.
  4. Add C:\tools\dart\bin to your PATH environment variable.

Solution 2: Add Dart to PATH

If Dart is already installed but not recognized, you need to configure the PATH variable:

  1. Press Win + R, type sysdm.cpl and hit Enter.
  2. Go to the Advanced tab and click Environment Variables.
  3. Under System variables, find Path and click Edit.
  4. Click New and add the Dart bin folder path, for example:
C:\tools\dart\bin

After updating, open a new terminal and run:

dart --version

You should now see the Dart version information instead of the error.

Solution 3: Use Dart via Flutter SDK

If you already have Flutter installed, Dart is bundled with it. In this case, you don’t need to install Dart separately, but you must add the Flutter bin directory to PATH.

For example, if you installed Flutter in C:\src\flutter, then add:

C:\src\flutter\bin

This way, both flutter and dart commands will be recognized in the terminal.

Example Case: Fixing the Error

Let’s say you installed Flutter but got the error when running dart pub get inside your project:

C:\my_project> dart pub get
'dart' is not recognized as an internal or external command,
operable program or batch file.

In this case, you need to add Flutter’s Dart path manually. The Dart executable is located inside Flutter’s bin cache:

C:\src\flutter\bin\cache\dart-sdk\bin

Add this directory to your PATH and restart your terminal. Now run:

dart pub get

The command should now work properly and download all dependencies.

Alternative: Run Dart Without PATH

If you don’t want to edit the PATH variable, you can run Dart by specifying the full path:

C:\src\flutter\bin\cache\dart-sdk\bin\dart.exe --version

This method works but is not practical for daily development. Setting PATH is the recommended solution.

Final Thoughts

The error “Dart Not Recognized as Internal or External Command” is common when setting up Flutter or Dart for the first time. By correctly installing the Dart SDK or using the bundled version inside Flutter, and updating the PATH environment variable, you can solve the issue quickly. Once fixed, you can start building and running your Dart and Flutter applications without interruptions.

rysasahrial

Leave a Reply

Your email address will not be published. Required fields are marked *