Kenzie Systems Logo

Install Node.js Linux Server

Build, package, and publish production-ready web projects.

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.

What you use Node.js for on Linux servers
Real-world
  1. Install dependencies using npm.
  2. Build for production (npm run build) to generate dist/ or build/.
  3. Publish the output folder behind Nginx/Apache (or inside a container).
  4. Optional: run Node as a server only if you have SSR (Next.js) or a Node API.
Important: For typical React/Vite apps, Node is needed to build. The final output is static files that your web server serves.

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).

Method A (recommended for servers): OS packages (NodeSource)
Stable + predictable

This installs Node.js system-wide and is ideal for production build servers and CI servers. Use LTS for stability.

Security note: Only run install scripts from trusted sources. Review commands before running them.

Ubuntu / Debian (LTS):

# 1) Update sudo apt-get update # 2) Install curl (if needed) sudo apt-get install -y curl ca-certificates # 3) Install Node.js LTS (example: 20.x LTS - adjust if your org standard differs) curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt-get install -y nodejs # 4) Confirm node -v npm -v

RHEL / CentOS / Rocky / AlmaLinux (LTS):

# 1) Update sudo dnf -y update || sudo yum -y update # 2) Install curl (if needed) sudo dnf -y install curl ca-certificates || sudo yum -y install curl ca-certificates # 3) Install Node.js LTS (example: 20.x LTS) curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash - sudo dnf -y install nodejs || sudo yum -y install nodejs # 4) Confirm node -v npm -v
Tip: On production servers, standardize the major version (ex: 20 LTS) so your builds are consistent.
Method B (good for developers): nvm (Node Version Manager)
Flexible

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.

# Install nvm (user-level) # (Run as the user who will build projects, not root) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash # Reload shell profile (or open a new terminal) export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Install and use an LTS version nvm install --lts nvm use --lts # Confirm node -v npm -v
Common nvm issue: Node works for your user but not for services/cron. That happens because nvm is user-scoped. For system services, prefer Method A.

Verify everything installed correctly

These checks confirm Node/npm are installed, PATH is correct, and your build toolchain can actually run.

1) Check Node and npm versions
Required
node -v npm -v

If you see version numbers, Node and npm are installed.

2) Confirm the binaries location
Recommended
which node which npm node -p "process.execPath"

This helps confirm you’re using the expected Node installation (system vs nvm).

3) Confirm npm can install packages
Recommended
mkdir -p ~/node-test && cd ~/node-test npm init -y

If it creates package.json, npm is working.

4) (Best test) Build a real production project
Production
# Inside your project folder npm install npm run build

Build outputs:
• Vite projects usually generate dist/
• CRA projects usually generate build/

Publish: deploy only the output folder behind Nginx/Apache (or upload it to a static host).

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.

Why production builds are important
Quality
  • 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.
Common Linux build dependencies
If builds fail

Some npm packages require native compilation. Install build essentials if you see errors related to node-gyp, make, g++, or Python.

Ubuntu / Debian:

sudo apt-get update sudo apt-get install -y build-essential python3 make g++

RHEL / Rocky / Alma / CentOS:

sudo dnf -y groupinstall "Development Tools" || sudo yum -y groupinstall "Development Tools" sudo dnf -y install python3 make gcc-c++ || sudo yum -y install python3 make gcc-c++
Tip: If your project builds without native modules, you might not need these packages. But they’re common on build servers.
Recommended checklist
Before go-live
  • node -v and npm -v show versions
  • which node points to expected install
  • npm install completes without errors
  • npm run build completes and generates output folder
  • Only dist/ or build/ is deployed
Official downloads (trusted)
Links

Best practice: pick one method and standardize across servers to avoid “works on my machine” builds.