Troubleshooting

Troubleshooting

Encountering issues with the project? This guide covers some common problems and their solutions.

Installation Issues

Error: Cannot find module 'next'

This error usually occurs when Next.js is not properly installed. Try the following:

  1. Delete the node_modules folder and package-lock.json file.
  2. Run npm install or yarn install again.
  3. If the issue persists, try installing Next.js explicitly:
    npm install next react react-dom

Build Errors

Error: Image Optimization using Next.js' default loader is not compatible with next export.

If you're using next export, you need to use a different image loader. Modify your next.config.js:

module.exports = {
  images: {
    loader: 'custom',
    loaderFile: './my-loader.js',
  },
}

Then create a my-loader.js file in your project root:

export default function myLoader({ src }) {
  return src
}

Runtime Errors

ReferenceError: window is not defined

This error occurs when trying to access the window object on the server side. Wrap your code in a check:

if (typeof window !== 'undefined') {
  // Your code here
}

Performance Issues

Slow Page Loads

  1. Ensure you're using production builds (next build and next start).
  2. Implement code splitting and lazy loading for large components.
  3. Optimize images and use Next.js Image component.
  4. Minimize CSS and JavaScript files.

If you encounter any issues not covered here, please check our GitHub issues or reach out to our support team.