Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."

I use next.js. When exporting a type in a file index.ts in a third party package an error occurs.

Module parse failed: Unexpected token (23:7)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > export type { Validate } from './src/nullable'
like image 879
Kiritushka Avatar asked Jan 26 '26 06:01

Kiritushka


1 Answers

in package.json, assuming the following dependency is added

"@yourproject/your-project": "file:../your-project",

then in next.config, add transpilePackages: ['@yourproject/your-project'],.  This allows the loader to work directly on .ts files.

transpilePackages: ['@yourproject/your-project'],
webpack: (config) => {
       config.resolve.extensionAlias = {
      ".js": [".ts", ".tsx", ".js", ".jsx"],
      ".mjs": [".mts", ".mjs"],
      ".cjs": [".cts", ".cjs"],
    };
    return config;
  },
like image 117
Smart Coder Avatar answered Jan 27 '26 22:01

Smart Coder