OpenViSTAI · Agents · Blockchain · Crypto
Menu

OPENVIST LEARN · FREE LESSONS

JavaScript in the browser and in Node.js

Choose the right runtime and run a saved JavaScript file without confusing it with a shell command.

Lesson 1 of 25 · About 15 minutes · Beginner · English

By the end of this lesson

Execute an .mjs file and explain where its code runs.

Before you start

  • Node.js 24 with a terminal and plain-text editor; the browser-only lesson is labelled separately.
  • No previous programming experience; no VPS purchase or paid API is required.

Three words to know

Runtime
The environment that executes JavaScript and supplies extra APIs.
Source file
A plain-text file containing program instructions.
Console
A place where a program can write messages.

1. One language, different environments

A browser can change a web page through document and other browser APIs. Node.js can read local files through its own APIs. JavaScript syntax is shared, but document is not available in a normal Node process, and node:fs is not a browser API. Reading this page does not execute the example on OpenViST. Most lessons use Node; lesson 18 provides a separate local browser example.

JavaScript source runs in a browser with page APIs or in Node.js with file and process APIs.
The language is shared; the host APIs are different.

2. Check Node before starting

Use Node.js 24 for this route. If it is missing, choose your operating system in the official Node download instructions linked below. Do not assume your Ubuntu default nodejs package is the same version. Open a new terminal after installation if the command is not found. node --version is a terminal command, not JavaScript source.

Check your runtimeTERMINAL · Bash or Windows PowerShell
node --version
What you should see · example output
v24.x.x (your patch version can differ)

3. Save and run one file

Create a fresh practice folder and a plain-text file named lesson.mjs. The .mjs extension explicitly selects JavaScript modules in Node, avoiding a package setting for now. Paste only source, without prompts or expected output. Save before running.

lesson.mjsJAVASCRIPT · Node.js · save as lesson.mjs
console.log("Hello, OpenViST!");
What you should see · example output
Hello, OpenViST!
Execute the saved fileTERMINAL · Bash or Windows PowerShell
node lesson.mjs
What you should see · example output
Hello, OpenViST!

If Node says the file cannot be found, check the terminal’s current folder and the exact filename. If you opened an interactive > prompt by running node without a filename, type .exit to return to the shell. The editor edits source; Node executes the saved source.

YOUR TURN

A small check before you continue

Change the greeting to Hello, learner! and rerun. Does a Node script automatically change the lesson page?

Show a suggested answer

The output changes in your terminal. Node has no automatic connection to this web page; editing browser content needs a browser program and its DOM APIs.

Sources and scope

Documentation and examples reviewed 2026-10-18. Provider screens, package versions and output wording can differ. Examples show expected outcomes; they are not a claim that OpenViST connected to your server or verified your setup.