Short answer
Look at the file path in the message. For .css, .scss, .ts, .tsx or .jsx files, add a module rule that sends that extension to the right loader (css-loader with style-loader, sass-loader, ts-loader or babel-loader). For images, fonts and SVG on webpack 5, add an asset rule (type: 'asset/resource') instead of an old file-loader. If the path is inside node_modules, the package ships syntax your build does not transpile: include that package in your babel-loader rule, or upgrade the build tool.
Why webpack can’t read the file, and the fix
01
No loader for that file type
“Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or “load” them.” webpack, Concepts: Loaders
Importing a stylesheet, a TypeScript file or JSX without a matching rule makes webpack try to read it as plain JavaScript, which fails on the first character. Install the loader and add a rule for the extension.
module.exports = { module: { rules: [ { test: /\.css$/i, use: ['style-loader', 'css-loader'] }, { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ }, ], }, resolve: { extensions: ['.tsx', '.ts', '.js'] }, };02
Images, fonts or SVG on webpack 5
webpack 5 handles these with built-in asset modules. A missing rule, or an old file-loader or url-loader config left from webpack 4, breaks on binary files.
{ test: /\.(png|jpe?g|gif|svg|woff2?)$/i, type: 'asset/resource' }03
Loaders in the wrong order
“Loaders are evaluated/executed from right to left (or from bottom to top).” webpack, Concepts: Loaders
Loaders in a use array run from the last one to the first. ['css-loader', 'style-loader'] or sass-loader placed first breaks the chain. Put style-loader first and the loader closest to the source file last.
{ test: /\.s[ac]ss$/i, use: ['style-loader', 'css-loader', 'sass-loader'] }04
A package in node_modules ships newer syntax
When the path in the error is inside node_modules, a dependency uses syntax (optional chaining, class fields) that an older webpack or Babel setup cannot parse, and the rule excludes node_modules. Transpile that one package, or upgrade webpack and react-scripts.
{ test: /\.m?js$/, include: [path.resolve(__dirname, 'src'), /node_modules[\\/]some-package/], use: 'babel-loader', }
Checked against the vendor’s docs on : webpack: Concepts: Loaders.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
Related: Vite “Failed to load module script” · “SyntaxError: Unexpected identifier” · Node.js “Cannot find module”