Skip to main content

Metro CLI Options

The metro command line runner has a number of useful options. You can run metro --help to view all available options. Here is a brief overview:

build <entry>​

Generates a JavaScript bundle containing the specified entrypoint and its descendants.

Options​

OptionAliasDescriptionValue
outOFile name where to store the output (required)String
platformpWhich platform to bundle for (e.g. web, android, ios)String
minifyzWhether Metro should minify the bundleBoolean
devgCreate a development build, in which __DEV__ is trueBoolean
configcLocation of the metro.config.js to useString
max-workersjThe number of workers Metro should parallelize the transformer on. Overrides maxWorkers which defaults to a number based on os.availableParallelism()Number
project-rootsPAccepted, but has no effectArray
source-mapWhether Metro should generate source mapsBoolean
source-map-urlURL where the source map can be foundString
legacy-bundlerAccepted, but has no effectBoolean
resolver-optionCustom resolver options of the form key=valueArray
transform-optiontransformer-optionCustom transform options of the form key=valueArray
reset-cacheDeprecated. Clears Metro's caches before building, like resetCacheBoolean
output-typetAccepted, but has no effectString

serve​

Alias: start

Starts Metro on the given port, building bundles on the fly. Restarts the server when the config file changes.

Options​

OptionAliasDescriptionValue
hosthHost to listen on. Defaults to localhostString
portpPort to listen on. Defaults to 8081, overriding server.portNumber
configcLocation of the metro.config.js to useString
max-workersjThe number of workers Metro should parallelize the transformer on. Overrides maxWorkers which defaults to a number based on os.availableParallelism()Number
secure-server-optionssOptions for the HTTPS server, using dot notation (e.g. -s.cert="$(cat path/to/cert)" -s.key="$(cat path/to/key)")Object
secureDeprecated. Serve over HTTPS. Use secure-server-options insteadBoolean
secure-keyDeprecated. Path to the key file for HTTPS when secure is setString
secure-certDeprecated. Path to the cert file for HTTPS when secure is setString
reset-cacheDeprecated. Clears Metro's caches on startup, like resetCacheBoolean
project-rootsPAccepted, but has no effectArray
hmr-enabledhmrAccepted, but has no effectBoolean

get-dependencies [entryFile]​

List all dependencies that will be bundled for a given entry point.

Options​

OptionDescription
entry-fileAbsolute path to the root JS file. This can also be given as the first positional arg.
outputFile name where to store the output, ex. /tmp/dependencies.txt
platformThe platform extension used for selecting modules
transformerSpecify a custom transformer to be used
max-workersSpecifies the maximum number of workers the worker-pool will spawn for transforming files. Overrides maxWorkers which defaults to a number based on os.availableParallelism().
devIf false, skip all dev-only code path. Defaults to true
verboseEnables logging. Defaults to false