Why Node.js matters for production
Node.js is the standard toolchain used to build modern web apps (React, Vite, Ant Design, etc.). Even if your final production app is served by Nginx/Apache (static files) or a reverse proxy, Node.js is what converts your source code into an optimized production build.
- Install dependencies using npm.
- Build for production (
npm run build) to generatedist/orbuild/. - Publish the output folder behind Nginx/Apache (or inside a container).
- Optional: run Node as a server only if you have SSR (Next.js) or a Node API.
Choose an installation method
On Linux servers, the recommended approach depends on whether you want a system-wide Node version (best for production) or user-managed versions (best for development).
This installs Node.js system-wide and is ideal for production build servers and CI servers. Use LTS for stability.
Ubuntu / Debian (LTS):
RHEL / CentOS / Rocky / AlmaLinux (LTS):
nvm lets each user install and switch Node versions without touching system packages. Great for development boxes. On servers, use it only if your team has a policy for it.
Verify everything installed correctly
These checks confirm Node/npm are installed, PATH is correct, and your build toolchain can actually run.
If you see version numbers, Node and npm are installed.
This helps confirm you’re using the expected Node installation (system vs nvm).
If it creates package.json, npm is working.
Build outputs:
• Vite projects usually generate dist/
• CRA projects usually generate build/
Production publishing notes
Your production build is what you deploy. It is optimized, stable, and predictable. Node helps you generate that build, then your web server serves it.
- Performance: bundles are minified and optimized.
- Cache & stability: hashed assets prevent broken browser caches.
- Consistency: same build output across machines.
- Security: you deploy compiled assets, not dev tooling.
Some npm packages require native compilation. Install build essentials if you see errors related to
node-gyp, make, g++, or Python.
Ubuntu / Debian:
RHEL / Rocky / Alma / CentOS:
-
node -vandnpm -vshow versions -
which nodepoints to expected install -
npm installcompletes without errors -
npm run buildcompletes and generates output folder - Only
dist/orbuild/is deployed
Best practice: pick one method and standardize across servers to avoid “works on my machine” builds.