Skip to content

Commit

Permalink
Update the Getting started guides
Browse files Browse the repository at this point in the history
  • Loading branch information
Aahil13 committed Apr 15, 2024
1 parent bdca9aa commit 75c808a
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 11 deletions.
40 changes: 38 additions & 2 deletions src/get-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,43 @@ title: Get started
index: false
icon: lightbulb
category:
- Getting started guide
- Getting started

footer: false
---

<AutoCatalog />
Hello there! 👋🏾 Welcome to the Node.js documentation! Let's get you started on how to navigate through this resource.

## How to Use This Guide

### Guides
In the [Get started](/get-started/) section, you'll find helpful guides to assist you in your Node.js journey. Whether you're looking to install Node.js, get started quickly with running your first application, or understand the core concepts of Node.js, you'll find everything you need here.

- **[Installation Guides](./installation.md)**: Need help setting up Node.js on your system? This guide has got you covered with step-by-step instructions.
- **[Quick Start](./quick-start.md)**: Dive right into coding with Node.js! This quick start guide will have you up and running with your first Node.js application in no time.
- **[Understanding Node.js](./what-is-nodejs.md)**: Curious about what Node.js is and how it works? This guide provides a straightforward explanation of the core concepts behind Node.js.

### Docs
In the [Docs](/docs/) section, you'll find detailed explanations of the fundamental concepts of Node.js. Whether you're interested in learning about Node.js modules, file system operations, or events, you'll find everything you need here.

### Examples
This course is structured to help you learn Node.js by doing. Under each concept in the [Docs](/docs/) section, you'll find examples that demonstrate how to apply the concepts in practice. The examples will look like this:

```js
var http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
}).listen(8080);
```

There are also some types of examples that you'll need to run via the command line. These examples will look like this:

```js
console.log('This example is different!');
console.log('The result is displayed in the Command Line Interface');
```

And that's it! You're all set to start your Node.js journey. If you have any questions or need help, feel free to reach out to us on [Twitter](https://twitter.com/nodejs) or [GitHub](https://github.com/nodejs/help) - we're here to help! 🚀

41 changes: 38 additions & 3 deletions src/get-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,42 @@ title: Installation guide
index: true
icon: screwdriver-wrench
category:
- Getting started
- Guides

footer: false
---

In this guide, we'll walk you through the process of installing Node.js on your system so you can start building awesome applications.

There are several way to install Node.js, including using a [package manager](https://nodejs.org/en/download/package-manager), downloading [prebuilt binaries](https://nodejs.org/en/download/prebuilt-binaries), or [building from source](https://nodejs.org/en/download/source-code). In this guide, we'll cover the most common method of installing Node.js using the official installer.

### Download Node.js
Visit [nodejs.org](https://nodejs.org/en/download) and download the appropriate installer for your operating system (Windows, macOS, or Linux).

### Run the Installer
Once the download is complete, run the installer and follow the on-screen instructions. The installer will guide you through the installation process, including selecting the installation directory and any additional options you may want to configure.

### Verify Installation
After the installation is complete, you can verify that Node.js and npm (Node Package Manager) are installed correctly by opening a terminal or command prompt and typing the following commands:

```bash
node -v
npm -v
```

These commands will display the versions of Node.js and npm installed on your system. If you see version numbers displayed, congratulations! You've successfully installed Node.js.

### Update npm (Optional)
It's a good idea to keep npm up to date. You can do this by running the following command:

```bash
npm install npm@latest -g
```

This will update npm to the latest version available.

That's it! You've now installed Node.js on your system. You're ready to write your [first Node.js program](./quick-start).

> [!note]
> If you ran into any issues during the installation process, feel free to report them on the [Node.js GitHub repository](https://github.com/nodejs/node/issues/)
footer:
---
39 changes: 37 additions & 2 deletions src/get-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,40 @@ icon: code
category:
- Getting started

footer:
---
footer: false
---

In this guide, we'll help you write your first program in Node.js. You'll create a simple HTTP server that listens on port 8080 and responds with "Hello, World!" when you visit `http://localhost:8080` in your browser.

## Prerequisites

Before you begin, make sure you have Node.js installed on your machine. If you haven't installed Node.js yet, you can follow the steps in the [installation guide](/get-started/installation).

### Create a New File
Open your favorite text editor and create a new file. You can name it whatever you like, but for this example, let's call it `hello.js`.

### Write Some Code
In your `hello.js` file, type the following code:

```js
var http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
}).listen(8080);
```

After writing the code, save the file.

### Run the Program
Open a terminal or command prompt and navigate to the directory where you saved `hello.js`. Then, type the following command:

```bash
node hello.js
```

### Access the Web Server
After running the command, your web server will start listening on port 8080. Open a web browser and navigate to `http://localhost:8080`. You should see the text "Hello World!" displayed in the browser.

Congratulations! 🎉 You've just created and ran your first Node.js web server. Now get ready to understand [how Node.js works](./what-is-nodejs.md)
28 changes: 24 additions & 4 deletions src/get-started/what-is-nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@ icon: book-open
category:
- Getting started

footer:
footer: false
---

Node.js is a runtime environment that allows you to run JavaScript code outside of a web browser. Instead of running JavaScript on the client-side (in a browser), Node.js enables you to run JavaScript on the server-side. It's commonly used for building web applications, APIs, and server-side scripting.
In this guide, we'll explore what Node.js is, how it works, and its various use cases.

Node.js simplifies the process of building scalable network applications. It's built on Chrome's V8 JavaScript engine, which makes it fast and efficient. With Node.js, you can handle thousands of simultaneous connections with ease, making it ideal for real-time applications like chat servers and streaming services.
## Understanding Node.js
Node.js is an open-source server environment that enables the execution of JavaScript code outside of a web browser. It's free, versatile, and runs seamlessly on various platforms including Windows, Linux, Unix, and macOS.

Node.js comes with a rich library of modules, making it easy to develop web servers and other network tools. These modules include functionalities for file system I/O, networking (HTTP, TCP, UDP, etc.), and even cryptography.
Unlike traditional web development, where JavaScript is mainly used for client-side scripting, Node.js enables you to execute JavaScript on the server-side.

### How Does Node.js Work?
At its core, Node.js is built on Chrome's V8 JavaScript engine, which makes it fast and efficient. It uses an event-driven, non-blocking I/O model, which means that it can handle thousands of simultaneous connections without getting bogged down by blocking operations.

### Why Node.js?
One of the key reasons Node.js stands out is its asynchronous programming model. Traditionally, web servers would wait while performing tasks like opening files.

Node.js, however, sends tasks to the computer's file system and proceeds to handle the next request without waiting. This non-blocking, asynchronous approach enhances efficiency and responsiveness, making Node.js an excellent choice for handling concurrent operations.

### Use Cases of Node.js
- **Generate Dynamic Page Content**: Node.js can dynamically generate web page content, making it a powerful tool for building dynamic web applications.
- **File System Operations**: With Node.js, you can perform various file system operations such as creating, opening, reading, writing, and deleting files on the server.
- **Handle Form Data**: Node.js can collect form data submitted by users on web forms.
- **Database Operations**: Node.js facilitates database operations, allowing you to add, delete, and modify data in your database.

### Anatomy of a Node.js File
Node.js files contain tasks that execute in response to specific events, such as a user attempting to access a port on the server. These files, typically denoted with a ".js" extension, must be initiated on the server to take effect.

With this foundational understanding of Node.js, you're ready to dive deeper into its capabilities and explore [server-side JavaScript development](/docs/).

0 comments on commit 75c808a

Please sign in to comment.