Next.js Discord

Discord Forum

Difference `npm run dev` and `npm run build` with `npm start`

Unanswered
American posted this in #help-forum
Open in Discord
Avatar
AmericanOP
Hi folks, I'm new to React JS and Next JS.
When I run the project via npm run dev command everything looks fine. However when I run npm run build with npm start it has missing UI/actions/requests.
Question: What is the main difference between npm run dev and npm run build with npm start? I am trying to run a project in a docker container. Any suggestion?

27 Replies

Avatar
Ray
npm run dev will start the dev server
npm run build then npm start will create a production build and start the server
it has missing UI/actions/requests.
do you have output: 'standalone' in next.config.js?
Avatar
AmericanOP
Hi, thanks for your reply. I confirm that there is no such output: 'standalone' in the next.config.js file. Should I add it to the next.config.js file?
I added it but it didn't help.
Avatar
Ray
are you trying it with just npm run build and npm start or in docker?
Avatar
AmericanOP
Yes I've run npm run build with npm start. without in docker.
Avatar
Ray
no css? are you using it with tailwind?
how did you create the project? with create-next-app?
Avatar
AmericanOP
Yes using it with tailwind.
I don't know exactly. I'll ask.
Project structure:
Image
Avatar
Ray
have you imported the global.css in layout.tsx?
Avatar
AmericanOP
Yes
Image
Avatar
Ray
can you try deploy it on vercel and share the url to me?
Avatar
AmericanOP
Sorry, I can't. what exactly are you trying to check? I will provide to you.
Avatar
Ray
check the url for the css
Avatar
AmericanOP
is that what you mean?
Image
Avatar
Ray
is it accessible?
Avatar
AmericanOP
Yes
Image
Avatar
Ray
but no style applied on the html?
Avatar
AmericanOP
they are used
Image
Avatar
Ray
ah what do you mean missing UI/actions/requests?
Avatar
AmericanOP
Missing UI:
Image
active chat panel missing
Missing requests:
first request missing in build version.
Avatar
Ray
is the page static generated? and doing client side fetching?
Avatar
AmericanOP
It's dynamic generated and doing it client side
Avatar
AmericanOP
Thanks! I've fixed it. It turns out that the wrong logic was written in useEffect