Hi, Iβm trying to use kokoro-js
in a Next.js 15 project, but I keep getting the following error:
Module not found: Can't resolve './'
./node_modules/kokoro-js/dist/kokoro.web.js:1:742149
However, when I test the same setup in a React + Vite project, it runs without any additional configuration and works as expected.
Hereβs my package.json
setup:
"kokoro-js": "^1.0.1",
"next": "^15.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
And my Next.js next.config.mjs
webpack configuration:
const nextConfig = {
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
sharp$: false,
"onnxruntime-node$": false,
"onnxruntime-web$": false,
};
return config;
},
};
export default nextConfig;
This is how I initialize kokoro-js in my worker.ts
file:
import { KokoroTTS } from "kokoro-js";
addEventListener(
"message",
async (event: MessageEvent<{ type: string; number: number }>) => {
const { type, number } = event.data;
console.log("Initializing model...");
const tts = await KokoroTTS.from_pretrained(
"onnx-community/Kokoro-82M-ONNX",
{
dtype: "q8",
}
);
}
);
Is there any known issue with using kokoro-js
in Next.js 15?
Since the same code runs fine in React + Vite without any extra setup, is there something specific I need to configure in Next.js to make kokoro-js
work properly?
Any help would be appreciated! Thanks.