dart: The Standalone VM

Send feedback

You can use the dart tool (bin/dart) to run Dart command-line apps such as server-side scripts, programs, and servers.

Basic usage

Here’s an example of running a Dart file on the command line:

dart test.dart


Common command-line options for dart include:

-c or --checked
Enables both assertions and type checks (checked mode).
Specifies the path to the package resolution configuration file. For more information, see Package Resolution Configuration File. This option cannot be used with --package-root.
-p <path> or -package-root=<path>
Specifies where to find imported libraries. This option cannot be used with --packages.
Sets the upper limit of old space to <num> MB.
Displays VM version information.
-h or --help
Displays help. (Add -v for information about all options.)

Observatory options

Observatory is a tool for profiling and debugging your apps. You can use the following flags to enable Observatory and to instruct the VM to delay the start up, or the exit, of an isolate:

Enables Observatory on localhost port 8181.
Enables Observatory on localhost for the specific port.
--enable-vm-service=<port>/<IP address>
Enables Observatory on an external network using the specified IP address and port. For example: --enable-vm-service=9999/
Causes the VM to pause each isolate that would otherwise exit. If your standalone app executes quickly, it might exit before you can open Observatory. To avoid this situation, specify this flag on startup. You must explicitly release all isolates in the Observatory debugger.
Causes the VM to pause before starting any isolate. You must explicitly start each isolate in the Observatory debugger.
A shortcut that combines --enable-vm-service and --pause-isolates-on-exit.
On Windows, Observatory’s CPU Profiler screen is disabled by default. Use this option to enable it.

The following is an example Observatory run:

$ dart --observe <script>.dart

For more information, see Observatory.

Snapshot option

You can also generate snapshots:

Generates a snapshot in the specified file. For information on generating and running snapshots, see the article Snapshots in Dart.

Enabling checked mode

Dart programs run in one of two modes: checked or production. By default, the Dart VM runs in production mode. We recommend that you enable checked mode for development and testing.

In checked mode, assignments are dynamically checked, and certain violations of the type system raise exceptions at runtime. In production mode, static type annotations have no effect.

Assert statements are also enabled in checked mode. An assert statement checks a boolean condition, raising an exception if the condition is false. Assertions do not run in production mode.

You can run the VM in checked mode with the --checked command-line flag:

dart --checked test.dart