About Node.js

Node.js is a powerful JavaScript runtime built on Chrome's V8 engine. It enables developers to run JavaScript outside the browser, making it ideal for building fast, scalable server-side and networking applications.

About npm init

npm init creates a package.json file, which stores project metadata, dependencies, and scripts.

Quick Start:

Popular Packages

Express

Minimal and flexible Node.js web application framework.

npm install express Starter code:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
    res.send('Hello, World!');
});

app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
                    
Mongoose

Elegant MongoDB object modeling for Node.js.

npm install mongoose Sample usage:
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/mydb')
    .then(() => console.log('Connected to MongoDB'))
    .catch(err => console.error(err));
                    

How to Start the Server?

  1. Open terminal in your project folder.
  2. Run node index.js (or your main file).
  3. Visit http://localhost:3000 in your browser.