Module parse failed ⚛️ React

Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type

Webpack found syntax it can’t parse because no loader is configured for that file (JSX, TypeScript, CSS, or modern syntax in node_modules).

Seen on: React

Meaning

Webpack needs loaders (babel-loader, ts-loader, css-loader). Packages shipping untranspiled modern syntax can also hit this in older webpack/babel setups.

Common causes

  • Missing babel-loader/ts-loader rule
  • JSX in .js files not covered by the rule
  • CSS/images without loaders
  • Dependency shipping newer syntax than your loader supports

⚡ Quick fix

  1. Add a rule for the file type
  2. Include the package in babel-loader’s transpiled modules
  3. Upgrade the toolchain (or move to Vite)

Detailed fix by platform

React

  1. { test: /\.[jt]sx?$/, exclude: /node_modules/, use: 'babel-loader' }

How to diagnose

  1. File — Which file and token?
  2. Loader — Is there a rule for it?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.