Node.js course · Part 1: The server side · lab 1 of 9
Node from zero: the server side
What changes when your JavaScript runs on a server instead of in a browser, what package.json is actually for, where secrets live, and why the difference between the two sides decides what is safe.
By the end you can
- Say what Node is and what it can do that a browser cannot
- Read a package.json and know what each part is for
- Keep secrets out of your code and out of your repository
- Decide correctly whether a piece of work belongs on the server or the client
Easier if you did first
step 1 of 3
What Node is, and what changes
Everything you wrote in the JavaScript course ran in a browser, on your visitor's device. Node is the same language running somewhere else: on a computer you control, with no page, no DOM and no visitor watching.
That one difference decides almost everything. There is no document and no window, because there is no page. There is a file system, a network and your environment, because it is a real machine.
And crucially: your visitors cannot read it. Browser code is downloaded and inspectable; server code is not. That is why keys, passwords and anything you must not leak live only on the server.
Node is also where your build tools run. When you type npm run build, that is Node. Next.js, the thing your own site is written in, is a Node program that renders pages on the server and sends them to the browser.
Four questions on the differences that matter before you write a line of it.
What these words mean
- Node
- JavaScript running outside a browser, on a server or your own machine.
- runtime
- The thing that actually runs your code: a browser, Node, Deno, Bun.
- server side
- Code your visitors cannot read, running on a machine you control.
- client side
- Code downloaded and run on the visitor's device.
- npm
- The tool that installs packages and runs your project's scripts.
question 1 of 4
Your Node script calls document.querySelector and crashes. Why?
question 2 of 4
Where should your Paystack secret key live?
question 3 of 4
Your form validates in the browser. Does the server still need to check?
question 4 of 4
Which of these belongs on the server?