Next.js Discord

Discord Forum

trouble deploying

Unanswered
chr.yx posted this in #help-forum
Open in Discord
I have the nextjs in the frontend sub dir and it has typescript and @types/node. Do i need to install it on the root directory for it to work?

63 Replies

backend stuff is in root dir
is this bad pratice
American Fuzzy Lop
No I’ve seen some people do it like this
American Fuzzy Lop
Ya this is definitely something I’ve seen
idk why on vercel is different
this is the settings i have on vercel:
American Fuzzy Lop
It might be due to the —prefix
Can you try rewriting the npm build command without it?
ok
would this work:

npm install && cd frontend && npm install && npm run build && cd ..
same error
American Fuzzy Lop
I believe you can just use the folder structure in your npm command like
"npm run backend build && npm run frontend build
but Im not 100% sure
ill try
American Fuzzy Lop
you might need to configure something else for this to work
@chr.yx ill try
American Fuzzy Lop
did it work?
nope
cause backend doesn't have a project init
American Fuzzy Lop
ya I think you need a package.json in both backend and frontend as well
but you can still do this structure to npm build them in parallel. Ive def seen it
oh ok
lemme search how to do
@chr.yx lemme search how to do
American Fuzzy Lop
ya sorry I havent personally worked w it.
np
thanks for ur time!
@chr.yx Click to see attachment
whats that?
is this some kind of express api in your backend
or something similar
yes
express
ok, and u made sure u can run your api with nodemon or whatever
yep
@chr.yx yep
and your fronted is a nextjs app?
ye
and you are directly deploying that to vercel using the nextjs config?
from vercel
through github repo
does it have a logo like this on top left
no
i feel like this is where i got it wrong
yeah thats not a good practice, u should deploy your next and api separately
u can keep both in the same project structure and use vercel cli
oh
is there docs on how to do that?
there are docs and im pretty sure there is a way for that
https://vercel.com/docs/cli/deploying-from-cli
u should ask here
if u really dont want to do that take a look at this
ok thanks
with that u can run two commands in the same npm script
@chr.yx is there docs on how to do that?
American Fuzzy Lop
if you need help doing it in this format I have done it like this on vercel