Netlify deployment issue

Hey, I've been deploying this project just fine 2 weeks ago but now it suddenly doesn't work. I did re-organize my component folder but I am not sure if this is what caused it, checked the imports 10 times and everything seems fine (it works locally). Error:
3:23:39 PM: $ npm run build
3:23:39 PM: > [email protected] build
3:23:39 PM: > tsc && vite build
3:23:41 PM: src/components/content/contentblock/ContentBlock.tsx(11,32): error TS2307: Cannot find module '../pages/projects/ProjectPageWrapper' or its corresponding type declarations.
3:23:41 PM: src/components/content/pages/Projects/ProjectPageWrapper.tsx(3,31): error TS2307: Cannot find module './projectnavigation/ProjectNavigation' or its corresponding type declarations.
3:23:41 PM: ​
3:23:41 PM: "build.command" failed
3:41:52 PM: Error message
3:41:52 PM: Command failed with exit code 2: npm run build (https://ntl.fyi/exit-code-2)
3:41:52 PM: ​
3:41:52 PM: Error location
3:41:52 PM: In build.command from netlify.toml:
3:41:52 PM: npm run build
3:41:52 PM: ​
3:41:52 PM: Resolved config
3:41:52 PM: build:
3:41:52 PM: base: /opt/build/repo
3:41:52 PM: command: npm run build
3:41:52 PM: commandOrigin: config
3:41:52 PM: publish: /opt/build/repo/dist
3:41:52 PM: publishOrigin: config
3:41:52 PM: redirects:
3:41:53 PM: - from: /*
status: 200
to: /index.html
redirectsOrigin: config
Caching artifacts
3:23:39 PM: $ npm run build
3:23:39 PM: > [email protected] build
3:23:39 PM: > tsc && vite build
3:23:41 PM: src/components/content/contentblock/ContentBlock.tsx(11,32): error TS2307: Cannot find module '../pages/projects/ProjectPageWrapper' or its corresponding type declarations.
3:23:41 PM: src/components/content/pages/Projects/ProjectPageWrapper.tsx(3,31): error TS2307: Cannot find module './projectnavigation/ProjectNavigation' or its corresponding type declarations.
3:23:41 PM: ​
3:23:41 PM: "build.command" failed
3:41:52 PM: Error message
3:41:52 PM: Command failed with exit code 2: npm run build (https://ntl.fyi/exit-code-2)
3:41:52 PM: ​
3:41:52 PM: Error location
3:41:52 PM: In build.command from netlify.toml:
3:41:52 PM: npm run build
3:41:52 PM: ​
3:41:52 PM: Resolved config
3:41:52 PM: build:
3:41:52 PM: base: /opt/build/repo
3:41:52 PM: command: npm run build
3:41:52 PM: commandOrigin: config
3:41:52 PM: publish: /opt/build/repo/dist
3:41:52 PM: publishOrigin: config
3:41:52 PM: redirects:
3:41:53 PM: - from: /*
status: 200
to: /index.html
redirectsOrigin: config
Caching artifacts
I looked through my Github history to double check, but I haven't changed my package.json or netlify.toml at all, nor any settings on Netlify. This project is React with Vite & TypeScript. My netlify.toml:
[build]
command = "npm run build"
publish = "/dist"
base = "/"

[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[build]
command = "npm run build"
publish = "/dist"
base = "/"

[[redirects]]
from = "/*"
to = "/index.html"
status = 200
16 Replies
aevitas
aevitasOP2y ago
Build command in package.json:
"build": "tsc && vite build"
"build": "tsc && vite build"
Already tried to clear cache and redeploy multiple times. Build settings in Netlify:
Build command: npm run build
Publish directory: dist
Build command: npm run build
Publish directory: dist
Any ideas?
b1mind
b1mind2y ago
The error tells you, you can also build locally it will give you same error Your missing imports in Content block component. So it very much had to do with you moving files 😅 Try npm run build locally and see though. If not it's still going to have something to do with the new import paths ( out side where they need to be?)
aevitas
aevitasOP2y ago
I tried that, this works fine locally
> tsc && vite build

vite v4.0.0 building for production...
✓ 101 modules transformed.
> tsc && vite build

vite v4.0.0 building for production...
✓ 101 modules transformed.
The imports that are missed are there, removed and added them again several times
b1mind
b1mind2y ago
mmm and the base and publish directories are right? that shouldn't matter though idk but the fact that it worked before and you only made changes with location of the components and that is your error its gotta be right >.>;; what are you building in/with vite? just a static page?
aevitas
aevitasOP2y ago
Base directory
Not set
Publish directory
dir
Base directory
Not set
Publish directory
dir
Yeah a fairly simple static page, just a portfolio
b1mind
b1mind2y ago
when you build does it create a dist folder on your local?
aevitas
aevitasOP2y ago
Yes
b1mind
b1mind2y ago
can you share your component file struct and the import statement that is failing
3:23:41 PM: src/components/content/contentblock/ContentBlock.tsx(11,32): error TS2307: Cannot find module '../pages/projects/ProjectPageWrapper' or its corresponding type declarations. 3:23:41 PM: src/components/content/pages/Projects/ProjectPageWrapper.tsx(3,31): error TS2307: Cannot find module './projectnavigation/ProjectNavigation' or its corresponding type declarations.
aevitas
aevitasOP2y ago
In contentblock:
import ProjectPageWrapper from "../pages/projects/ProjectPageWrapper";
import ProjectPageWrapper from "../pages/projects/ProjectPageWrapper";
aevitas
aevitasOP2y ago
I'm either stupid or it should be correct 😉
b1mind
b1mind2y ago
I see Projects/ProjectPageWrapper above src/components/content/pages/Projects/ProjectPageWrapper double check your capitalization folders imo should always be lower case paths/* I see in the folders they are but check the import Could it be something with the Types then? Like you changed the path to the components but the types are still pulling the capital folder names? 🤷‍♂️
aevitas
aevitasOP2y ago
3:23:41 PM: src/components/content/pages/Projects/ProjectPageWrapper.tsx(3,31): error TS2307: Cannot find module './projectnavigation/ProjectNavigation' or its corresponding type declarations.
3:23:41 PM: src/components/content/pages/Projects/ProjectPageWrapper.tsx(3,31): error TS2307: Cannot find module './projectnavigation/ProjectNavigation' or its corresponding type declarations.
You mean this right? I am not sure where they're getting this from.. Well jesus christ So it seems on github the folder IS 'Projects' eh Well it's fixed, it seems folder name changes (from capital to non capital letters) don't always push properly to Github.. Holy this was frustrating to fix
b1mind
b1mind2y ago
oh snap that is interesting!
aevitas
aevitasOP2y ago
I made new folders with a temporary name, pushed that, then made the proper folders
b1mind
b1mind2y ago
What was the fix? more than just re commiting? ah gotcha yea what a pain always use lower case for folder/paths 😄 so this is good to know glad you got it working!! 💪
aevitas
aevitasOP2y ago
Yeah it somehow slipped in there while making files Thanks as always 😉
Want results from more Discord servers?
Add your server