'"You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file." in react Next.js

I am using next.js and get this error from library files.

I think it requires to add some loader but I don't know how can do it.

error - ./node_modules/@jup-ag/core/node_modules/@saberhq/stableswap-sdk/node_modules/@saberhq/token-utils/dist/esm/common.js 8:9
Module parse failed: Unexpected token (8:9)
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
| import { Keypair, PublicKey, SystemProgram, Transaction, } from "@solana/web3.js";
| import { deserializeAccount, deserializeMint, MintLayout, Token } from ".";
> export * as token from "./token";
| /**
|  * Default number of decimals of a token.

This is source code for common.js

import { __awaiter } from "tslib";
import { Token as SPLToken, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { Keypair, PublicKey, SystemProgram, Transaction, } from "@solana/web3.js";
import { deserializeAccount, deserializeMint, MintLayout, Token } from ".";
export * as token from "./token";
/**
 * Default number of decimals of a token.
 */
export const DEFAULT_TOKEN_DECIMALS = 6;
...

This is my next.config.js

webpack: (config, params) => {
config.node = {
  fs: 'empty'
};

config.module.rules.push({
  test: /\.(eot|woff|pdf|woff2|ogg|mp3|wav|ttf|otf|ico|mpe?g)$/i,
  loader: "file-loader",
  options: {
    name: "[path][name].[ext]",
  },
});

config.module.rules.unshift({
  test: /pdf\.worker\.(min\.)?js/,
  use: [
    {
      loader: "file-loader",
      options: {
        name: "[contenthash].[ext]",
        publicPath: "_next/static/worker",
        outputPath: "static/worker"
      }
    }
  ]
});

if (config.module.css) {
  config.module.css.config.plugins.push(
    new FilterWarningsPlugin({
      exclude: /mini-css-extract-plugin[^]*Conflicting order between:/,
    })
  );
}

return config;

Please let me know what loader should I add in this config file.

Please help me



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source