VS Code keeps producing dev version
Unanswered
Great black wasp posted this in #help-forum
Great black waspOP
Hi ! I am having this issue: when I run "npm run build" and deploy to server, it turns out to be a development version ????
Interestingly, when I run npm run build and then npm run start locally , I do get production version !!!
Does anyone have any ideas ? How to solve this ?
Interestingly, when I run npm run build and then npm run start locally , I do get production version !!!
Does anyone have any ideas ? How to solve this ?
54 Replies
Rainbow trout
Where are you running your build and where do you deploy it?
Great black waspOP
Windows with node
.next folder created with npm run builld
Locally runs as production
On server, same .next folder runs as development 🙂
Rainbow trout
Are you self hosting next or using a cloud provider like Vercel?
Great black waspOP
No, shared windows hosting with node support
Worked great so far
I deployed last month, everything was ok
Last night - problems 🙂
I am doing something wrong, just cant figure it out 🙂
When you run npm run build, it does create new files, and I never deploy before build, so it should not be cashing issue....
I also executed npm run build from actual terminal outside vs code, so I dont think it is vs code issue
Rainbow trout
That's odd
Great black waspOP
The only difference is that i have node 18, and server has node 20
Rainbow trout
shouldn't make any difference
Great black waspOP
Right
And i did not touch vs code for.a.month
🙂
Env is also set to production...
I know I missed.something and I will lough at myself later, but now I am simply stuck 🙂
Trll me, when you insall dependencies, you just type npm install ?
Or should I install them gobally ?
Rainbow trout
I use pnpm, but yes, simply npm install
try adding this in your package.json under scripts
then simply run
"scripts": {
"deploy": "next build && next start",
}
then simply run
npm run deploy
Great black waspOP
I will
The weird thing is that i do get production version on my pc
Then I immediately copy .next to server, and I get development version:)
Rainbow trout
You shouldn't just copy the .next folder to your server, you have to build the app on your server using
next build
Great black waspOP
It should produce same .next ?
Iz worked fine last month
Next6.kopljar.com
Same process, production version
Webstorm1.kopljar.com
Same process, development version
Same local settings, same hosting server, same deployment 😞
Same server.js and web.config
Rainbow trout
you definitely have to run the build command on your server
Great black waspOP
I just compared .next on my pc and on server, they are NOT same 🙂
Great black waspOP
there are some weird issues with upload 🙂
Rainbow trout
because you're not supposed to just upload the
.next
directory to your serverjust run the build command on your server and start the app afterwards
Great black waspOP
That was not the case before though....
At least with this server
I would build locally and deploy .net and node_modules
Since it is shared windows server
Now it has obviously changed
And as it is shared srrver, i can not just run build command
So when I update code, I ll see how to procede....
.next not .net
Great black waspOP
There must have been some issues with the server .... I just made it to work by deploying ONLY .next, node_modules and public folders together with package.json, server.js and web.config (as it is Windows server).
The recommended way to do whatever you are trying to do is via standalone output:
https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
Then you just need to upload the standalone folder to your server, that folder has everything the app needs to run.
.next from next build on one machine is NOT guaranteed to work on another machine especially if there is a difference in OS, arch, or set up workflows.
https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
Then you just need to upload the standalone folder to your server, that folder has everything the app needs to run.
.next from next build on one machine is NOT guaranteed to work on another machine especially if there is a difference in OS, arch, or set up workflows.
Great black waspOP
you are absolutely right ! But I checked and both OS, node and npm are compatible. I will surely check this standalone output ! Thank you !
Great black waspOP
OK, the problem was on the server (shared hosting, sorry... 🙂 It seems node was not enabled 🙂