Search code examples
react-typescript

React typescript barrel export not working after renaming file


I had 2 component files, one was Navigation.tsx and other one was NavigationList.tsx. I merged that components into one and renamed NavigationList.tsx into Navigation.tsx and deleted origial Navigation.tsx (also renamed NavigationList function into Navigation) and got error on server start:

export 'Navigation' (imported as 'Navigation') was not found in 'modules'

I found solution that worked for some guy here on stack to restart computer and clear cache but didn't work for me. When I make default export it works, but I don't want defalut export neither full path import in another component. Any1 have any suggestion for another solution?

Also my project structure looks like this:

--/src
---/modules
----/index.ts
----/header
----/index.ts
-----/components
------/Navigation.tsx
------/index.ts
---/views
----/header
-----/Header.tsx <= importing Navigation into Header.tsx

Solution

  • If anyone have problems like this, and neither solution works for you, just delete node_modules and install again, that fixed my problem.