layout | title | description | permalink | short-title |
---|---|---|---|---|
default |
dart: The Standalone VM |
The reference page for 'dart' at the command line. |
/dart-vm/tools/dart-vm |
dart |
You can use the dart tool (bin/dart
) to run Dart command-line apps such as
server-side scripts, programs, and servers.
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:
--enable-asserts
: Enables assert
statements. When asserts are enabled, an
assert statement
checks a boolean condition, raising an exception if the condition is false.
--packages=<path>
: 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
.
--old_gen_heap_size=<num>
: Sets the upper limit of
old space to <num>
MB.
--version
: Displays VM version information.
-h
or --help
: Displays help. (Add -v
for information about all 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:
--enable-vm-service
: Enables Observatory on localhost port 8181.
--enable-vm-service=<port>
: 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/0.0.0.0
--pause-isolates-on-exit
: 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.
--pause-isolates-on-start
: Causes the VM to pause before starting any isolate.
You must explicitly start each isolate in the
Observatory debugger.
--observe
: A shortcut that combines --enable-vm-service
and
--pause-isolates-on-exit
.
--profile
: 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.
You can also generate snapshots:
--snapshot=<filename>
: Generates a snapshot in the specified file. For information
on generating and running snapshots, see
Snapshots on GitHub.