Node.js 与 NPM 入门
了解 Node.js 是什么、它在后端开发中的优势,以及如何使用 Node 包管理器(NPM)。
Node.js 与 NPM 入门 是 CoddyKit 上的免费 Node.js Backend Development Bootcamp 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Node.js Backend Development Bootcamp 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Node.js Backend Development Bootcamp 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Welcome to Node.js!
Node.js is a server-side JavaScript runtime — an engine that runs your JS outside the browser, right on a server or your own machine.
Why Node.js is Awesome
Why developers love Node.js: one language front to back, blazing V8 speed, non-blocking I/O for high concurrency, and the massive NPM ecosystem.
How Node.js Works
Node uses an event-driven, non-blocking model: it kicks off a task, registers a callback, and moves on — handling tons of connections without waiting around.
Checking Your Node.js Setup
Check your setup with node -v. See a version number? You're good. If not, grab it from nodejs.org.
Your First Node.js Script
Let's write a classic Hello, World. Drop a console.log into a file named app.js — that's a full Node script.
// app.js
console.log("Hello from CoddyKit Node.js!");Running Your Node.js Code
Run it with node app.js from its folder. Node executes the script and prints your message to the terminal.
Meet NPM (Node Package Manager)
NPM (Node Package Manager) ships with Node and is the world's largest software registry. It installs third-party packages, shares your code, and tracks dependencies.
Starting a New Project with NPM
Start a project with npm init. It walks you through creating package.json — the file holding your project's metadata and dependency list.
Installing Packages with NPM
Add a library with npm install express. NPM downloads it into node_modules and records it in your package.json.
Quick Check on Node.js & NPM
Let's test your understanding of Node.js and NPM.
Recap: Node.js & NPM Fundamentals
You've got the basics: Node.js runs JS on the server, and NPM manages packages via node, npm init, and npm install. Next: modules.
常见问题解答
「Node.js 与 NPM 入门」课时是免费的吗?
是的 — 「Node.js 与 NPM 入门」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Node.js Backend Development Bootcamp 课程的其余内容,请升级到 CoddyKit PRO。 Node.js Backend Development Bootcamp 课程共包含 4 节课。
「Node.js 与 NPM 入门」这节课中我会学到什么?
了解 Node.js 是什么、它在后端开发中的优势,以及如何使用 Node 包管理器(NPM)。 你通过在浏览器中直接运行的动手代码来练习 Node.js Backend Development Bootcamp,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Node.js Backend Development Bootcamp 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Node.js Backend Development Bootcamp 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。
「Node.js 与 NPM 入门」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Node.js Backend Development Bootcamp 课中编写并运行代码吗?
能。每节 Node.js Backend Development Bootcamp 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- Node.js 与 NPM 入门
- 详解 Node.js 模块系统
- 异步 JavaScript 与事件循环
- 使用文件系统与流