Node.js 24 cheatsheet

Node.js 24: Getting started

6 common Node.js 24 tasks.

Check the Node.js version

Print the installed Node.js version.

node --version

Run a script

Run a JavaScript file with Node.js.

node app.js

Run a one-line expression

Evaluate a snippet and print the result without creating a file.

node -p "process.versions.v8"

Open the interactive shell

Start the REPL to try out expressions. Exit with .exit or Ctrl+D.

node

Restart on file changes

Re-run the script automatically whenever it or its imports change.

node --watch app.js

Load environment variables from a file

Read variables from a .env file into process.env before the script starts.

node --env-file=.env app.js

Was this page helpful?