Registry / web-framework / babel-preset-react-native

babel-preset-react-native

JSON →
library4.0.1jsnpmunverified

A Babel preset for React Native applications, providing the default Babel configuration used by React Native's Metro bundler. This preset is deprecated and has been replaced by metro-react-native-babel-preset for React Native v0.57 and later. The last version (4.0.1) supports Babel 6; users on newer versions must migrate. Key differentiator: it was the official preset before React Native switched to Babel 7, enabling custom Babel configs while preserving baseline transforms.

npm install babel-preset-react-native
INSTALL
IMPORT
SIG · BABEL-PRESET-REACT
B
babel-preset-react-native
web-frameworkjavascriptv4.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = { presets: ['babel-preset-react-native'] };
import { reactNative } from 'babel-preset-react-native';
This is a CommonJS Babel preset, typically defined in .babelrc as a string. No ESM import path exists.
react-native
{ "presets": ["react-native"] }
{ "presets": ["babel-preset-react-native"] }
In .babelrc, Babel resolves the preset name; 'react-native' is the shorthand, 'babel-preset-react-native' also works but is longer.
require('babel-preset-react-native')
const preset = require('babel-preset-react-native');
import preset from 'babel-preset-react-native';
ESM import does not work because the package only provides a CommonJS module. Use require() for programmatic use.

Minimal .babelrc configuration to use the deprecated babel-preset-react-native in React Native apps using Babel 6.

{ "presets": ["react-native"] }
Debug
Known issues
deprecatedbabel-preset-react-native is deprecated. Use metro-react-native-babel-preset for React Native v0.57+.
fix
Replace 'babel-preset-react-native' with 'metro-react-native-babel-preset' in your Babel config.
affects: >=0.57
breakingbabel-preset-react-native@4 only supports Babel 6, not Babel 7. React Native v0.57 requires Babel 7.
fix
Install metro-react-native-babel-preset@5 or later, which supports Babel 7.
affects: >=0.57
gotchaDefining a custom .babelrc completely overrides React Native's default Babel config, including necessary transforms.
fix
Ensure your .babelrc includes the preset to restore defaults, and avoid removing essential plugins for RN.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'babel-preset-react-native'
The package is not installed or is not in node_modules.
fix
Run 'npm install babel-preset-react-native --save-dev' (or the correct package for your RN version).
Error: Plugin/Preset files are not allowed to export objects, only functions.
Using babel-preset-react-native@4 with Babel 7 which expects function exports.
fix
Upgrade to metro-react-native-babel-preset which exports a function compatible with Babel 7.
Warning: `metro-react-native-babel-preset` is included in the project's config while `babel-preset-react-native` is also present. Please remove the old preset.
Both old and new presets are configured, causing duplicate transforms.
fix
Remove 'babel-preset-react-native' from your Babel config and dependencies.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
babel-preset-react-native — npm install babel-preset-react-native · libregistry