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.
Note
console.log(...) is JavaScript’s way of printing a line, the same idea as echo in the . When you run a JS file from the terminal, that is where its output shows up.
Quick check
What is Node.js, in one line?
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.
Quick check
A README says to run `npm install` before anything else. What is that doing?
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.
Tip
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.
Quick check
You run `npm -v` and get `npm: command not found`. What is the problem?
Try it
Note
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.
node -v— a version number comes back, so Node is available.ls— seeapp.jssitting in the folder.node app.js— run it and read the output.
Three commands, and you have run a program from the terminal.