> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NodeJS Application Overview

> This article provides an overview of setting up a minimal Node.js application and preparing for a custom GitHub Action workflow.

Node.js is a powerful, open-source JavaScript runtime built on Chrome’s V8 engine. It enables you to execute JavaScript on the server side, allowing you to use a single language across your entire stack. In this guide, we’ll explore the basics of a minimal Node.js project and prepare for creating a custom GitHub Action workflow.

<Callout icon="lightbulb" color="#1CB2FE">
  Node.js runs on Windows, macOS, and most Linux distributions. Ensure you’re using a supported version for compatibility.
</Callout>

## Prerequisites

Verify your installed versions:

```bash theme={null}
$ node -v
v18.16.0

$ npm -v
9.8.1
```

> You should have Node.js (v14+) and npm installed.\
> If not, download them from [Node.js Official Site][nodejs].

## Project Structure

A minimal Node.js project typically includes these elements:

| Item           | Description                                                           |
| -------------- | --------------------------------------------------------------------- |
| package.json   | Metadata: name, version, dependencies, and custom scripts.            |
| node\_modules/ | Automatically generated by `npm install`; contains all your packages. |
| index.js       | Entry point for your application—your core business logic.            |
| test.js        | Unit tests and integration tests for your functions and endpoints.    |

## Installing Dependencies

Install all required libraries listed in `package.json`:

```bash theme={null}
npm install
```

<Callout icon="lightbulb" color="#1CB2FE">
  This command reads `package.json` and populates the `node_modules/` directory with every dependency.
</Callout>

## Running Tests

Execute your tests as defined in the `test` script of `package.json`:

```bash theme={null}
npm test
```

A successful run will output results and confirm that all test cases pass.

## Starting the Application

Launch the server using the `start` script:

```bash theme={null}
npm start
```

By default, the app listens on port 3000. Verify the endpoint:

```bash theme={null}
curl http://localhost:3000/hello
# Expected output: Hello World!
```

<Callout icon="triangle-alert" color="#FF6B6B">
  If port 3000 is in use, modify the port in `index.js` or set the `PORT` environment variable before starting.
</Callout>

***

With your Node.js application up and running, you’re now ready to integrate it into a custom GitHub Action. In the next section, we’ll build a workflow file that automates tests and deployment.

## Links and References

* [Node.js Official Site][nodejs]
* [npm Documentation][npm]
* [GitHub Actions][gh-actions]

[nodejs]: https://nodejs.org/

[npm]: https://docs.npmjs.com/

[gh-actions]: https://docs.github.com/actions/overview

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/github-actions-certification/module/56d72a06-285c-4516-9880-073fb56f579b/lesson/02991ce3-eae5-4497-85f9-5ec12eaee9c3" />
</CardGroup>
