JSX transform failures occur when your build tool cannot convert JSX syntax into JavaScript, typically due to missing Babel plugins, incorrect configuration, or version mismatches between React and your build tooling.
JSX transform failures happen when the build process cannot convert JSX syntax into regular JavaScript that browsers can execute. JSX is not valid JavaScript - it's a syntax extension that needs to be transformed (transpiled) by tools like Babel or TypeScript before it can run. When this transformation fails, your build process stops and you cannot run your React application. This error commonly appears in several forms: "Support for the experimental syntax 'jsx' isn't currently enabled", "Cannot find module '@babel/plugin-transform-react-jsx'", or "'jsx' is not exported by node_modules/react/jsx-runtime.js". Each variation points to different configuration issues in your build pipeline. The transformation process involves either the classic transform (converting JSX to React.createElement calls) or the newer automatic runtime introduced in React 17 (which auto-imports special functions from react/jsx-runtime). Failures can occur at any stage - missing dependencies, incorrect Babel configuration, TypeScript compiler settings, or version incompatibilities between React and build tools.
Check your .babelrc, babel.config.js, or package.json for Babel configuration. Ensure you have @babel/preset-react in the presets array:
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}If using the new automatic JSX runtime (React 17+), configure it explicitly:
{
"presets": [
["@babel/preset-react", { "runtime": "automatic" }]
]
}The runtime: "automatic" option enables the new transform that doesn't require importing React in every file.
Install the required Babel packages if they're missing:
npm install --save-dev @babel/preset-react @babel/plugin-transform-react-jsxOr with Yarn:
yarn add --dev @babel/preset-react @babel/plugin-transform-react-jsxIf you recently ejected from Create React App or suspect corrupted dependencies, delete node_modules and reinstall:
rm -rf node_modules package-lock.json
npm installEnsure your Babel version is 7.9.0 or higher for new JSX transform support: npm list @babel/core.
If using TypeScript, verify your tsconfig.json has the correct jsx setting:
For React 17+ with automatic runtime:
{
"compilerOptions": {
"jsx": "react-jsx"
}
}For React 16 and earlier (classic runtime):
{
"compilerOptions": {
"jsx": "react"
}
}The react-jsx option uses the new automatic runtime, while react uses the classic React.createElement transform.
The automatic JSX runtime requires React 17.0.0 or later. Check your current version:
npm list reactIf below 17.0.0 and you've configured automatic runtime, either upgrade React:
npm install react@latest react-dom@latestOr revert your Babel/TypeScript configuration to use classic runtime by removing "runtime": "automatic" from Babel preset options and setting TypeScript's jsx to "react" instead of "react-jsx".
Ensure your build tool recognizes JSX syntax in your files:
Webpack: Verify babel-loader processes .jsx and .js files containing JSX:
module.exports = {
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
}
};Vite: Add esbuild jsx configuration if using .js files with JSX:
export default {
esbuild: {
loader: 'jsx',
include: /src/.*\.jsx?$/,
}
}Alternatively, rename files with JSX from .js to .jsx extension.
If JSX transform fails in Jest tests, ensure your Jest configuration includes proper transformation:
In jest.config.js or package.json:
module.exports = {
transform: {
'^.+\.(js|jsx|ts|tsx)$': 'babel-jest'
}
};Install babel-jest if missing:
npm install --save-dev babel-jestEnsure your .babelrc or babel.config.js is in the project root where Jest can find it.
If your terminal is in a directory accessed via symbolic links, React's build tools may fail to resolve modules correctly. Get the real path:
pwd -PNavigate to the actual path (not the symlink) and run your build command:
cd $(pwd -P)
npm startThis ensures Create React App and other tools resolve dependencies from the correct absolute path.
ESLint Configuration: When using automatic JSX runtime, you can disable the react/jsx-uses-react and react/react-in-jsx-scope ESLint rules since importing React is no longer necessary. Add to your .eslintrc:
{
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
}
}Pragma Conflicts: Avoid mixing JSX pragmas (/** @jsx */ or /** @jsxFrag */) with automatic runtime - you'll get "pragma and pragmaFrag cannot be set when runtime is automatic". Remove pragma comments when using runtime: "automatic".
Build Tool Differences: Different build tools handle JSX transformation differently. Create React App includes all necessary configuration out of the box, Vite uses esbuild for fast transformation, and custom Webpack setups require explicit babel-loader configuration. If migrating between tools, verify each tool's JSX handling requirements.
Monorepo Considerations: In monorepos with hoisted dependencies, ensure @babel/preset-react is installed at the workspace root or configure Babel to resolve presets from the correct location using the rootMode option.
React Native Web: When using react-native-web, packages may fail with JSX syntax errors if they're not transpiled. Configure your build tool to process specific node_modules packages that contain untranspiled JSX.
Prop spreading could cause security issues
Prop spreading could cause security issues
Error: error:0308010C:digital envelope routines::unsupported
Error: error:0308010C:digital envelope routines::unsupported
React Hook "useEffect" is called conditionally. React Hooks must be called in the exact same order in every component render.
React Hook useEffect placed inside a condition
Hook can only be called inside the body of a function component
Hook can only be called inside the body of a function component
Rollup failed to resolve import during build
How to fix "Rollup failed to resolve import" in React