LinuxCommandLibrary

metro

TLDR

Start Metro bundler

$ npx react-native start
copy
Start with cache reset
$ npx react-native start --reset-cache
copy
Start on specific port
$ npx react-native start --port [8082]
copy
Bundle for production
$ npx react-native bundle --entry-file [index.js] --bundle-output [bundle.js]
copy
Enable verbose logging
$ npx react-native start --verbose
copy

SYNOPSIS

metro [options]

DESCRIPTION

Metro is the JavaScript bundler used by React Native. It compiles and bundles JavaScript code and assets, handles module resolution, and provides hot reloading during development.
Metro is optimized for React Native's requirements with fast incremental builds.

PARAMETERS

--port port

Server port.
--reset-cache
Clear bundler cache.
--verbose
Verbose output.
--config file
Config file path.
--entry-file file
Entry point file.
--bundle-output file
Output bundle file.
--platform platform
Target platform.

CONFIGURATION

$ // metro.config.js
module.exports = {
  resolver: {
    sourceExts: ['js', 'jsx', 'ts', 'tsx'],
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: { experimentalImportSupport: false },
    }),
  },
};
copy

CAVEATS

React Native specific. Cache issues may require reset. Port conflicts with multiple instances.

HISTORY

Metro was developed by Facebook (Meta) as the bundler for React Native, optimized for mobile development workflows.

SEE ALSO

react-native(1), webpack(1), babel(1), expo(1)

Copied to clipboard