What Is Node.js?
Node.js is a JavaScript runtime built on Google’s high-performance V8 engine. It lets you run JavaScript outside the browser, so you can build server-side apps, CLI tools, and more—all with the same language you use in the browser. Node.js supports Windows, macOS, and Linux.For production environments, use the Long-Term Support (LTS) version of Node.js. Manage multiple versions easily with tools like nvm.
Node Package Manager (npm)
When you install Node.js, you also get npm—the package manager that helps you discover, install, and manage JavaScript libraries and dependencies. With npm you can:- Share code with the community via the npm registry
- Install and update packages with a single command
- Define project scripts for testing, building, and running your app
Sample Node.js Project Structure
A minimal Node.js project often includes these three files:| File | Purpose |
|---|---|
| package.json | Metadata (name, version) and dependency definitions |
| index.js | Application entry point and core logic |
| test.js | Automated tests for your code |
node_modules folder with all packages you need.
Common npm Commands
| Command | Description |
|---|---|
| npm install | Install project dependencies |
| npm test | Run tests defined in test.js |
| npm start | Launch the application (e.g., server) |