Cannot find module '...' or its corresponding type declarations. (NextJS + TypeScript)

Viewed 1144
  • In my NextJs project, I have created cookie.ts file in utils folder.
  • When I run "npm run dev" and when I check my application on localhost:300 it works fine, code from my file in utils/cookie.ts is fetched and everything seems ok without any errors.
  • When I push my changes to gitlab then build fails with the error "Cannot find module '../utils/cookies' or its corresponding type declarations."

Here is screenshot from gitlab:

enter image description here

Project structure:

enter image description here

1 Answers

It is fixed.

How I fixed it:

In my nextjs app, there is docker configuration included.

So I had to add this new folder (utils) to docker configuration.

Related