How to clean cache in Next.js

1. Anser
– yarn cache clean
– rm -rf node_modules/
– rm -rf .next/

2. Reference
https://stackoverflow.com/questions/69084610/how-to-clean-cache-in-next-js-react-chrome

3. Confirm used disk size

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs             802196      1972    800224   1% /run
/dev/sda2      503115808 179234908 298250540  38% /
tmpfs            4010972     62128   3948844   2% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
/dev/sda1         523244      5364    517880   2% /boot/efi
tmpfs             802192      4760    797432   1% /run/user/1000

4. Yarn cache clean

$ yarn cache clean
yarn cache v1.22.19
success Cleared cache.
Done in 8.29s.
$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs             802196      1972    800224   1% /run
/dev/sda2      503115808 176441744 301043704  37% /
tmpfs            4010972     61872   3949100   2% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
/dev/sda1         523244      5364    517880   2% /boot/efi
tmpfs             802192      4760    797432   1% /run/user/1000
$

5. Remove the whole node_modules

$ rm -rf node_modules/
$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs             802196      1972    800224   1% /run
/dev/sda2      503115808 175907464 301577984  37% /
tmpfs            4010972     61872   3949100   2% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
/dev/sda1         523244      5364    517880   2% /boot/efi
tmpfs             802192      4760    797432   1% /run/user/1000
$ 

6. Re install node modues

$ yarn

7. Comfirm execute
– ok

$ npm run dev

8. Confirm used disk size

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs             802196      1972    800224   1% /run
/dev/sda2      503115808 177697888 299787560  38% /
tmpfs            4010972     61872   3949100   2% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
/dev/sda1         523244      5364    517880   2% /boot/efi
tmpfs             802192      4760    797432   1% /run/user/1000
$

9. Delete .next/

$ rm -rf .next/

10. Confirm used disk size

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs             802196      1972    800224   1% /run
/dev/sda2      503115808 174595404 302890044  37% /
tmpfs            4010972     61872   3949100   2% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
/dev/sda1         523244      5364    517880   2% /boot/efi
tmpfs             802192      4760    797432   1% /run/user/1000
$

11. Comfirm execute
– ok

$ npm run dev