Type error: Cannot find module <filename> or its corresponding type declarations

Hi there,

I have problem with deploying my project on Netlify, cause of error ‘Type error: Cannot find module or its corresponding type declarations.’ - https://gradebookk.netlify.app/

When I build project on my computer in VSC all works good, app is building without problems.

But when I am trying to deploy this app from my github (https://github.com/tomaszz95/gradebook) deployment is failing and errors pop up.

9:47:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:47:02 PM: Netlify Build                                                 
9:47:02 PM: ────────────────────────────────────────────────────────────────
9:47:02 PM: ​
9:47:02 PM: ❯ Version
9:47:02 PM:   @netlify/build 29.18.1
9:47:02 PM: ​
9:47:02 PM: ❯ Flags
9:47:02 PM:   baseRelDir: true
9:47:02 PM:   buildId: 64d3ed171c3ff20008c0d3cf
9:47:02 PM:   deployId: 64d3ed171c3ff20008c0d3d1
9:47:02 PM: ​
9:47:02 PM: ❯ Current directory
9:47:02 PM:   /opt/build/repo
9:47:02 PM: ​
9:47:02 PM: ❯ Config file
9:47:02 PM:   No config file was defined: using default values.
9:47:02 PM: ​
9:47:02 PM: ❯ Context
9:47:02 PM:   production
9:47:02 PM: ​
9:47:02 PM: ❯ Installing plugins
9:47:02 PM:    - @netlify/plugin-nextjs@4.39.3
9:47:14 PM: ​
9:47:14 PM: ❯ Using Next.js Runtime - v4.39.3
9:47:15 PM: ​
9:47:15 PM: @netlify/plugin-nextjs (onPreBuild event)                     
9:47:15 PM: ────────────────────────────────────────────────────────────────
9:47:15 PM: ​
9:47:15 PM: No Next.js cache to restore.
9:47:15 PM: Netlify configuration property build.environment.NEXT_PRIVATE_TARGET value changed.
9:47:15 PM: ​
9:47:15 PM: (@netlify/plugin-nextjs onPreBuild completed in 16ms)
9:47:15 PM: ​
9:47:15 PM: Build command from Netlify app                                
9:47:15 PM: ────────────────────────────────────────────────────────────────
9:47:15 PM: ​
9:47:15 PM: $ npm run build
9:47:15 PM: > gradebook@0.1.0 build
9:47:15 PM: > next build
9:47:15 PM: - warn No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
9:47:15 PM: - info Linting and checking validity of types...
9:47:18 PM: Failed to compile.
9:47:18 PM: 
9:47:18 PM: ./src/components/timetable/TimetableBody.tsx:1:26
9:47:18 PM: Type error: Cannot find module './TimetableRow' or its corresponding type declarations.
9:47:18 PM: > 1 | import TimetableRow from './TimetableRow'
9:47:18 PM:     |                          ^
9:47:18 PM:   2 | 
9:47:18 PM:   3 | import { TimetableDataType } from '../helpers/types'
9:47:18 PM:   4 | import styles from './TimetableBody.module.css'
9:47:18 PM: ​
9:47:18 PM: build.command failed                                        
9:47:18 PM: ────────────────────────────────────────────────────────────────
9:47:18 PM: ​
9:47:18 PM:   Error message
9:47:18 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:47:18 PM: ​
9:47:18 PM:   Error location
9:47:18 PM:   In Build command from Netlify app:
9:47:18 PM:   npm run build
9:47:18 PM: ​
9:47:18 PM:   Resolved config
9:47:18 PM:   build:
9:47:18 PM:     command: npm run build
9:47:18 PM:     commandOrigin: ui
9:47:18 PM:     environment:
9:47:18 PM:       - NEXT_PRIVATE_TARGET
9:47:18 PM:     publish: /opt/build/repo/.next
9:47:18 PM:     publishOrigin: ui
9:47:18 PM:   plugins:
9:47:18 PM:     - inputs: {}
9:47:18 PM:       origin: ui
9:47:18 PM:       package: '@netlify/plugin-nextjs'
9:47:19 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:47:19 PM: Failing build: Failed to build site
9:47:20 PM: Finished processing build request in 46.875s

I checked filenames in case of typo, I checked files in case of bad import path - everything is working and seems good (on PC site is running and building well). I even did absolute paths to components files from ‘./src’ and deployment also was failing. I send you screen of error, config and my project is in my git repository linked higher.
I also commented that one page (timetable page, in this app is many more) and tried to deploy app without it - same error was in console but then with other sites - like this problem is about every component, netflify complains about every import of component in my app… No idea why…



Screenshot_4

Rest of screens

Check if your git repo has the correct case for file names: