Node.js and Vite: a complete overview, pros, cons and limits

What Node.js and Vite are used for: 8 areas, pros and cons, what is built into Node.js today, Vite 8 with Rolldown, a comparison with Deno, Bun, PHP and Go, code examples, limits and tips.

Stack and technologies Updated

In short

Node.js runs JavaScript and TypeScript outside the browser: on a server, in scripts and in the tools that build every modern front end. Its strengths are one language for front and back end, non-blocking input and output that holds thousands of connections, the largest package registry in the world and, in recent versions, a lot built in — fetch, a test runner, SQLite, running .ts files directly. Vite is the build tool on top of it: an instant dev server and an optimised production build, used by Vue, Svelte, Astro, React Router and Laravel. Together they are the standard kitchen of web development; the cost is dependency weight and the habit of pulling a package for every trifle.

Node.js and Vite at a glance

The main facts about both tools in one table.

Node.js
A JavaScript runtime on Google’s V8 engine; Ryan Dahl, 2009; OpenJS Foundation; MIT licence
How it works
One thread with an event loop; input and output do not block
Versions
Even-numbered versions become LTS and are supported for 30 months
TypeScript
Recent versions run .ts files directly by erasing the types
Built in
fetch, a test runner, watch mode, .env loading, node:sqlite
Packages
npm — the largest package registry in the world, millions of packages
Vite
A build tool by Evan You, 2020; developed by VoidZero together with Rolldown, Oxc and Vitest
In development
Serves native ES modules; a change appears in the browser at once, without a full rebuild
For production
Vite 8 builds with Rolldown, a bundler written in Rust
Who uses Vite
Vue, SvelteKit, Astro, React Router, Nuxt, Laravel
Alternatives
Runtimes — Deno and Bun; build tools — webpack, esbuild, Rspack

What Node.js and Vite are used for: 8 areas

Node.js is everywhere JavaScript needs to run outside the browser; Vite — wherever front-end code needs building.

  1. 01

    Building the front end

    Scripts and styles minified, versioned by hash and split into chunks.

    ViteRolldown

  2. 02

    APIs and services

    Backends that share types with the interface.

    FastifyHonoNestJS

  3. 03

    Real time

    Chats, notifications and live dashboards over WebSockets.

    WebSocketSocket.IO

  4. 04

    Server rendering of React and Vue

    Pages come ready from the server and then come alive in the browser.

    Next.jsNuxtAstro

  5. 05

    Telegram bots

    Bots and the backend of Mini Apps in one language with the interface.

    grammY

  6. 06

    Scripts and automation

    Imports, reports and data processing on a schedule.

    node:sqlitecron

  7. 07

    Developer tools

    Linters, formatters and test runners for JavaScript run on Node.js.

    ESLintPrettierVitest

  8. 08

    Desktop apps

    Electron combines Node.js and a browser engine.

    Electron

Pros and cons of Node.js and Vite

The strengths come from one language everywhere and a huge ecosystem; the weak spots — from the same ecosystem.

Pros · 8

  • One language

    Front end, back end, scripts and tools — in JavaScript or TypeScript.

  • Thousands of connections

    Non-blocking I/O holds many open connections on modest hardware.

  • A package for everything

    The largest registry: almost any integration already exists.

  • More is built in

    fetch, tests, SQLite and .env without extra packages.

  • An instant dev server

    Vite shows a change in the browser at once, even in big projects.

  • A fast production build

    Rolldown in Vite 8 is written in Rust and builds many times faster than older tools.

  • Works with any backend

    A manifest tells PHP or Go which hashed files to include.

  • Many developers

    JavaScript is one of the most widespread languages — the team is easy to find.

Cons · 8

  • Dependency weight

    A typical project pulls hundreds of packages and hundreds of megabytes of node_modules.

  • Supply-chain risk

    A compromised package deep in the tree reaches every project that uses it.

  • CPU-heavy work blocks

    One long calculation stops the event loop for everyone; it needs worker threads.

  • Modules ESM and CommonJS

    Two module systems still cause configuration pain.

  • Frequent changes

    Tools and their settings change from version to version — projects need updating.

  • Hosting

    A long-running Node.js server needs a VPS or a platform, not shared hosting.

  • A package for every trifle

    The habit of adding a dependency for three lines of code grows the risk and the weight.

  • Memory

    A Node.js process uses more memory than a comparable Go service.

Node.js compared with Deno, Bun, PHP and Go

A qualitative comparison of runtimes for the server side.

CriterionNode.jsDenoBunPHPGo
Language JS / TS JS / TS JS / TS PHP Go
Maturity the highest of the three mature young very high high
npm compatibility native high high — —
Long connections natively natively natively with extra tools natively
Heavy computing worker threads workers workers weak strong
Hosting VPS or platform VPS or Deno Deploy VPS any VPS, one file
Best for APIs, real time, tooling secure scripts and edge fast scripts and tooling sites, shops, admin panels high-load services

When to choose Node.js — and when not to

Twelve typical tasks with a verdict. Where Node.js is not the best choice, the alternative is named.

  • Building any front end

    Best fit

    Vite is the standard, even for PHP and Go sites.

  • API for a React interface

    Best fit

    Shared types between the server and the screen.

  • Chat and live notifications

    Best fit

    WebSockets are native to the event loop.

  • Next.js or Nuxt site

    Best fit

    Server rendering requires Node.js.

  • Telegram bot

    Best fit

    Mature libraries and the same language as the Mini App.

  • Scripts and imports

    Best fit

    Built-in fetch and SQLite cover a lot without packages.

  • A corporate site

    Works

    For the build — yes; for the server — PHP or static pages are simpler to host.

  • Background job queues

    Works

    BullMQ works well; for huge streams look at Go.

  • Shared hosting only

    Pick another

    PHP — it runs everywhere.

  • Very high load with heavy computing

    Pick another

    Go or Rust.

  • Machine learning

    Pick another

    Python.

  • Very little memory

    Pick another

    Go: a compact binary.

The Node.js ecosystem: tools for common tasks

The middle column is what is built into Node.js itself.

TaskBuilt inTools
Build — Vite, Rolldown, esbuild
HTTP server node:http Fastify, Hono, Express
HTTP client fetch undici
Tests node:test Vitest
Database node:sqlite pg, mysql2, Drizzle, Prisma
Environment variables --env-file dotenv
Restart on change --watch nodemon
Queues — BullMQ
Running TypeScript type stripping tsx
Packages npm pnpm, Yarn
Process manager — systemd, PM2

The limits of Node.js and common mistakes

  1. A long calculation in a request

    Resizing images or parsing a huge file in the main thread stops every other request.

  2. Unhandled errors

    A rejected promise without a handler can bring the whole process down.

  3. Dependencies without control

    No lock file and no audit — and a new version of someone else’s package changes your project.

  4. Secrets in the bundle

    Variables prefixed for the client get into the browser — keys must stay on the server.

  5. An old Node.js version

    Versions out of support get no security fixes.

  6. A process without a supervisor

    If nothing restarts the server after a crash, the site stays down until someone notices.

8 tips for Node.js and Vite

  1. 01

    An LTS version

    Production runs on the current LTS; odd versions are for experiments.

  2. 02

    Built-in first

    fetch, node:test, node:sqlite and --env-file before reaching for a package.

  3. 03

    A lock file in the repository

    npm ci installs exactly the versions that were tested.

  4. 04

    Audit dependencies

    npm audit and fewer packages — every dependency is someone else’s code in your project.

  5. 05

    Heavy work in worker threads

    worker_threads or a queue keep the event loop free.

  6. 06

    A supervisor for the process

    systemd or PM2 restart the server after a crash and on reboot.

  7. 07

    Vite manifest for server sites

    The backend reads manifest.json and includes files with hashes — caching without stale versions.

  8. 08

    Measure the bundle

    Check what each dependency adds to the size the user downloads.

What Node.js and Vite look like: 4 examples

An API and its test on built-in modules only, a price-list import into built-in SQLite and a Vite build for a server-rendered site. Run in Node.js 22 and Vite 8, checked by TypeScript 7.

An API without packages

A server on node:http — nothing to install, nothing to update.

server.ts
// an API on built-in modules only: no packages to install or update
import { createServer } from 'node:http';

const products = [
  { sku: 'A-100', title: 'Oak table', price: 24000 },
  { sku: 'B-200', title: 'Pine shelf', price: 5000 },
];

export const server = createServer((req, res) => {
  const url = new URL(req.url ?? '/', 'http://localhost');
  if (url.pathname === '/api/products') {
    const max = Number(url.searchParams.get('max') ?? Infinity);
    res.writeHead(200, { 'content-type': 'application/json' });
    res.end(JSON.stringify(products.filter((p) => p.price <= max)));
    return;
  }
  res.writeHead(404).end();
});

A test with the built-in runner

node --test runs it; fetch and assertions are built in.

server.test.ts
// the test runner and fetch are built in too
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { server } from './ex1.en.ts';

test('filters products by price', async () => {
  server.listen(0);
  const { port } = server.address() as { port: number };
  const res = await fetch(`http://localhost:${port}/api/products?max=10000`);
  assert.deepEqual(await res.json(), [{ sku: 'B-200', title: 'Pine shelf', price: 5000 }]);
  server.close();
});

A price-list import

Built-in SQLite and one transaction: a repeated run updates prices instead of duplicating rows.

import.ts
// a price-list import: built-in SQLite, one transaction, no dependencies
import { DatabaseSync } from 'node:sqlite';
import { readFileSync } from 'node:fs';

const db = new DatabaseSync('shop.db');
db.exec('CREATE TABLE IF NOT EXISTS prices (sku TEXT PRIMARY KEY, price INTEGER NOT NULL) STRICT');

const rows = readFileSync('prices.csv', 'utf8').trim().split('\n').slice(1);
const upsert = db.prepare(
  'INSERT INTO prices (sku, price) VALUES (?, ?) ON CONFLICT (sku) DO UPDATE SET price = excluded.price',
);

db.exec('BEGIN');
for (const row of rows) {
  const [sku, price] = row.split(',');
  upsert.run(sku!, Number(price));
}
db.exec('COMMIT');

const { n } = db.prepare('SELECT count(*) AS n FROM prices').get() as { n: number };
console.log(n); // 2 — a repeated import updates prices instead of duplicating rows

Vite for a server-rendered site

The build gives files with hashes and a manifest — the backend includes the right version.

vite.config.ts
import { defineConfig } from 'vite';

// Vite builds scripts and styles for a server-rendered site (PHP, Go)
export default defineConfig({
  build: {
    outDir: 'public/build',
    manifest: true, // manifest.json: which hashed file to include on the page
    rolldownOptions: {
      input: ['src/main.ts', 'src/style.css'],
    },
  },
});

Questions about Node.js and Vite

What is Node.js in simple terms?

A program that runs JavaScript outside the browser — on a server, in scripts and in developer tools.

What is Vite for?

To develop with instant updates in the browser and to build compact files for production.

Does a PHP site need Node.js?

Only for building scripts and styles; Node.js does not run on the production server.

Node.js, Deno or Bun?

Node.js is the most mature and compatible. Deno and Bun are faster in places and run TypeScript out of the box, but are younger.

Which Node.js version should I use?

The current LTS — an even-numbered version supported for 30 months.

Can Node.js run TypeScript without a build?

Yes, recent versions erase the types on the fly; the types are checked separately by tsc.

Vite or webpack?

For new projects — Vite: faster to develop and simpler to set up. webpack remains in many existing projects.

Where to host a Node.js server?

On a VPS under systemd or on a platform; shared hosting usually does not run long-lived processes.

Online form

Node.js
and Vite

I use Node.js and Vite for builds, services and scripts: fast front-end builds for server-rendered sites, small APIs, imports and automation. Tell me about the task — I answer within one working day.

Or write to [email protected]