Node.js CLI Performance & Profiling

Node.js CLI performance cheat sheets for memory tuning, CPU profiling, heap analysis, coverage, and source-map-aware debugging.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Memory, Profiling, and Coverage

Tune heap sizes and collect performance data.

Increase max old space size

Raise the V8 heap ceiling in MiB.

bashANYnodememoryv8
bash
node --max-old-space-size=4096 app.js
Notes

Common for builds, SSR, and memory-heavy workloads.

Generate V8 profile log

Record profiling output for CPU analysis.

bashANYnodeprofilingcpu
bash
node --prof app.js
Notes

Useful in performance debugging workflows.

Generate CPU profile

Collect a CPU profile for DevTools analysis.

bashANYnodeprofilingcpu
bash
node --cpu-prof app.js
Notes

Modern performance workflow for realistic workloads.

Generate heap profile

Record heap allocation data.

bashANYnodeprofilingheap
bash
node --heap-prof app.js
Notes

Helpful when tracking memory growth and allocations.

Write heap snapshot on signal

Generate heap snapshots on demand.

bashANYnodeheapsignals
bash
node --heapsnapshot-signal=SIGUSR2 app.js
Notes

Useful for long-running services where you want snapshots without stopping the process.

Trace GC activity

Print V8 garbage collection events.

bashANYnodegc
bash
node --trace-gc app.js
Notes

Helpful when investigating memory pressure or GC pauses.

Write V8 coverage output

Collect coverage JSON into a directory.

bashANYnodecoveragev8
bash
NODE_V8_COVERAGE=./coverage node app.js
Notes

Useful for diagnostics or integrating with coverage tooling.

Enable source maps in stack traces

Map stack traces back to original sources.

bashANYnodesource-maps
bash
node --enable-source-maps dist/server.js
Notes

Important for transpiled TypeScript or bundled code.

Recommended next

No recommendations yet.