dart: The Standalone VM

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 --enable-asserts test.dart


Common command-line options for dart include:

Enables assert statements. When asserts are enabled, an assert statement checks a boolean condition, raising an exception if the condition is false.
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 Snapshots on GitHub.