Lesson 29 / 30
Publishing to npm
Publish a package to the npm registry: unique name, versioning, npm login, bin field and npm publish.
What publish needs
A unique name, a version, an npm login, and a bin field if it's a CLI tool — then npm publish uploads it to the registry.
publish workflow
Bump the version before every publish — npm rejects re-publishing the same version number.
npm login
npm version patch # 1.0.0 -> 1.0.1
npm publishQuick check: Why does npm version patch matter before publishing an update?
- npm refuses to publish a version number that already exists on the registry
- It compiles the code
- It deletes the previous version
- It uploads the code automatically
Answer
npm refuses to publish a version number that already exists on the registry — The registry treats each version as immutable — you must bump the number to publish new changes.
Final quiz 1 of 8
Final quiz
Quick check: What makes Node able to handle many connections with one thread?
- One thread per request
- Compiling to C++
- Non-blocking I/O and the event loop
- A built-in database
Answer
Non-blocking I/O and the event loop — Waiting I/O is handed off while the loop serves other work.
Final quiz 2 of 8
Final quiz
Quick check: Which field enables ES module syntax in package.json?
- "main": "esm"
- "es": true
- "import": "all"
- "type": "module"
Answer
"type": "module" — Set type to module (or use .mjs).
Final quiz 3 of 8
Final quiz
Quick check: What does ^4.19.2 allow?
- Minor and patch updates below 5.0.0
- Only patch updates
- Major updates
- No updates
Answer
Minor and patch updates below 5.0.0 — Caret allows compatible updates within the same major version.
Final quiz 4 of 8
Final quiz
Quick check: Why use fs/promises inside a server handler?
- It is shorter
- It does not block the event loop
- It encrypts files
- It needs no import
Answer
It does not block the event loop — Async file calls let other requests continue.
Final quiz 5 of 8
Final quiz
Quick check: Which method connects a readable stream to a writable stream with backpressure?
- push
- emit
- pipe (or pipeline)
- spawn
Answer
pipe (or pipeline) — pipe and stream.pipeline manage flow control for you.
Final quiz 6 of 8
Final quiz
Quick check: How do you run independent async calls together?
- Await them one by one
- setTimeout
- process.exit
- Promise.all
Answer
Promise.all — Promise.all runs them concurrently and waits for all.
Final quiz 7 of 8
Final quiz
Quick check: What should you do after an uncaughtException?
- Log it and exit the process
- Ignore it
- Retry forever
- Delete node_modules
Answer
Log it and exit the process — The process may be in an unknown state, so exit and let a supervisor restart it.
Final quiz 8 of 8
Final quiz
Quick check: Which Node module moves CPU-heavy work off the main thread?
- path
- worker_threads
- os
- dotenv
Answer
worker_threads — Worker threads keep the event loop responsive.