# What node and npm actually are

Course: Terminal Basics — https://zero2vibecode.com/learn/terminal-basics
Canonical URL: https://zero2vibecode.com/learn/terminal-basics/4-1-what-node-and-npm-are

Node runs JavaScript files outside a browser. npm fetches code other people wrote. Almost every "run this to set up the project" instruction is one of those two.

Two names you will meet in the first five minutes of any project's README. They are much simpler than they sound.

## node — runs JavaScript files

JavaScript started as a language for web pages, running inside a browser. **Node.js** is a program that runs JavaScript *outside* a browser — as an ordinary command-line program.

```
node app.js
```

That reads `app.js`, runs it, and prints whatever it prints. If the file contains:

```
console.log('Hello from Node')
```

then you see:

```
Hello from Node
```

That is the whole relationship. `node` is the engine; your `.js` file is the instructions.

`console.log(...)` is JavaScript's way of printing a line, the same idea as `echo` in the shell. When you run a JS file from the terminal, that is where its output shows up.

## npm — fetches other people's code

Almost nobody writes a project entirely from scratch. You use libraries: a date handler, a web framework, a test runner.

**npm** (Node Package Manager) is the tool that downloads them. It comes bundled with Node, so installing one gives you both.

```
npm install
```

That reads the project's list of required packages and fetches every one of them. This is the command behind most "just run this to set up the project" instructions.

## Checking whether they are there

```
node -v
npm -v
```

Each prints a version number. A version means the tool is installed and the shell can find it.

If instead you get:

```
node: command not found
```

that is not a typo — it means Node is not installed on this machine, or it is installed somewhere the shell does not look. Either way, the fix is installation, not retyping.

`command not found` always means the same thing, for any command: the shell searched its list of program folders and came up empty. It is a "not installed" message, not a "you spelled it wrong" message.

## Try it

Fair warning: this simulator does not really run JavaScript. It reads your file, finds the `console.log` lines, and prints what they would print. Enough to learn the workflow, not a real Node install.

1. `node -v` — a version number comes back, so Node is available.
2. `ls` — see `app.js` sitting in the folder.
3. `node app.js` — run it and read the output.

Three commands, and you have run a program from the terminal.
