Fixing LlamaIndex Configuration Issues in Next.js
LlamaIndex not working in your Next.js project? This short guide might fix it.
I had issues with llamaIndex
in a Next.js because of sharp
and/or onnxruntime-node
. Thankfully it's an easy fix.
Follow these steps to update your next.config.js
file:
- Open your
next.config.js
file: Locate this file in the root directory of your Next.js project.
Update the next.config.js
configuration with the following:
/** @type {import('next').NextConfig} */ const nextConfig = { // (Optional) Export as a static site // See https://nextjs.org/docs/pages/building-your-application/deploying/static-exports#configuration output: "export", // Feel free to modify/remove this option // Override the default webpack configuration webpack: (config) => { // See https://webpack.js.org/configuration/resolve/#resolvealias config.resolve.alias = { ...config.resolve.alias, sharp$: false, "onnxruntime-node$": false, }; return config; }, }; export default nextConfig;
- Restart your development server: Run
npm run dev
oryarn dev
to restart the Next.js development server.