I get module not found error when using bun
Problem Description
When using bun, you might encounter an error like this:
Cannot find package 'intlayer' from '/workspace/packages/@intlayer/config/dist/cjs/utils/ESMxCJSHelpers.cjs' undefinedReason
Intlayer use require internally. And bun scope the require function to resolve only the packages of the @intlayer/config package, instead of the whole project.
Solution
Provide the require function in the configuration
const config: IntlayerConfig = { build: { require, },};export default config;next.config.ts
Copy code
Copy the code to the clipboard
import { withIntlayer } from "next-intlayer/server";const configuration = withIntlayer({ require,});export default configuration;