The Be Sure Blog

Code Snippets | Problem Solving | Tips & Tricks

The Be Sure Blog banner

How to clear the cache of a Next.js application

posted on 4.4.2023 by Below Surface in "Next.js"

After getting the following build error when generating the static pages for my Next.js 13 ISR application:

> Build error occurred
Error: Export encountered errors on following paths:
        /(post)/[postUrl]/page: /find-out-the-event-type-of-a-html-input-change-in-vs-code
        /category/[categoryUrl]/page: /category/interview-questions
    at C:\Users\....

I quickly figured out that the URL


and the category


were both changed or deleted in the database. After trying to rebuild the app a few times with

$ npm run build

and getting the same error, I figured that there must be cached data of previous Next.js builds. As a working solution I just deleted to .next folder in the root directory of Next.js and then ran

$ npm run build

again. Problem solved!


build error occured
static page generation

More posts of this category

Do a static export of a Next.js website

Doing a static export in Next.js is easy and working great on basic web hosting services


Change the port of a Next.js app

How to manually set the port from 3000 to any other number


Next.js 13 - how to set dynamic HTML head titles

How to take a slug string and turn it into a HTML title tag


Suppress Next.js img tag warnings

If you don't want to use their Image elements, this is how to disable the warnings


Add a robots.txt to your Next.js website

How to add your robots.txt file


Add Tailwind CSS to your Next.js app

A few commands and some possible error fixing and you are good to go!


Next.js 13 Tailwind CSS hot-reload issue fix

With the currently experimental app directory, hot-reload does not work properly


How i finally fixed "sh: 1: next: not found"

My release pipeline failed constantly and it took me three hours to figure out the issue


How I fixed "Parsing error: DeprecationError"

'originalKeywordKind' has been deprecated since v5.0.0 (...)