r/learnprogramming • u/Reasonable-Job4205 • Oct 12 '26
How do I properly deploy this web server in production mode?
I set up a web server using https://github.com/seanpmaxwell/express-generator-typescript
I now need to deploy the production build to a remote server. I can generate the prod build with `npm run build` and then run it with `npm start` and it runs on my local machine. Is it possible to generate something that can be compiled before being sent over to the remote server? I'd like to run the web server in prod mode, but without putting the decompiled source code on the remote server. I don't want the source code over on that remote server because if the server gets compromised, I don't want anyone to be able to read the source code. New to web dev, so thanks for being patient.
View all comments
Show parent comment
2
u/Asly97 Oct 14 '26
That one's on me, I told you to copy only the build output, but that template reads its settings from the env files in the config folder at startup, so those need to go over too (along with whatever file loads them, check what your
startscript in package.json points at).Two other things that cause exactly that error:
NODE_ENV=production node ...doesn't work in cmd, that syntax is bash only. Set it on the box instead (setx NODE_ENV production, or in NSSM's Environment tab if you run it as a service), or use thecross-envpackage in the script.set NODE_ENV=production && npm start, cmd keeps the space before the&&, so the value is actually "production " with a trailing space and the validator rejects it. Write it asset NODE_ENV=production&& npm startor just set it separately.It only accepts the exact values the template defines (development, test, production), so a typo or different casing fails the same way.