Loïc Boset
Loïc Boset

Reputation: 523

Nextjs trying to find a file that doesn't exist anymore

I changed a file name from columns.tsx to columns.ts but Nextjs is still looking for the columns.tsx file. If I rename the file back to columns.tsx, it's now trying to find the columns.ts version.

This is while running next dev. I tried next build but without success.

If I make a copy of the file to have one columns.ts and one columns.tsx then it works.

Any clue as to why it happens and how to fix it?

wait  - compiling...
error - ./components/ui/tables/ReactTable/columns.tsx
Error: Failed to read source code from [...]/components/ui/tables/ReactTable/columns.tsx

Caused by:
    No such file or directory (os error 2)

Upvotes: 12

Views: 7114

Answers (2)

trailing slash
trailing slash

Reputation: 891

I had a similar problem, where I kept getting TypeScript type errors for a file in my Nextjs app that didn't exist any more. Just deleting .next/ didn't work, so I used a bigger hammer and it worked:

rm -rf .next
rm -rf node_modules
npm install
tsc --build --clean

Upvotes: 0

Loïc Boset
Loïc Boset

Reputation: 523

I solved it by deleting the .next folder that includes the cache.

Upvotes: 28

Related Questions