> For the complete documentation index, see [llms.txt](https://docs.discloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.discloud.com/development-environment/supported-languages/javascript/package-json.md).

# package.json

## 🗂️ O que é `package.json`?

O arquivo `package.json` é essencial para gerenciar metadados e dependências de projetos Node.js. Ele garante que as bibliotecas necessárias sejam instaladas automaticamente ao hospedar sua aplicação na Discloud.

***

## 🛠️ Como Criar `package.json`

Para gerar o arquivo `package.json` para seu projeto, siga os passos abaixo:

{% stepper %}
{% step %}
**Abra o terminal no diretório do seu projeto**

No Windows, use **Shift + Clique Direito** e selecione "Abrir PowerShell".
{% endstep %}

{% step %}
**Execute o seguinte comando para criar o `package.json` automaticamente:**

```bash
npm init -y
```

Este comando criará um arquivo `package.json` no diretório do seu projeto.
{% endstep %}
{% endstepper %}

***

## 📝 Estrutura do `package.json`

Após a criação, o arquivo `package.json` deve se parecer com isso:

{% code title="package.json" %}

```json
{
  "name": "discloud",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {}
}
```

{% endcode %}

{% hint style="info" %}
Se você quiser hospedar um bot **Discord.js** ou qualquer outro framework, você precisará adicionar dependências ao `package.json`. Verifique a próxima seção para aprender como fazer isso.
{% endhint %}

***

## 📦 Adicionando Dependências

Para adicionar dependências, use o comando `npm install`, que adicionará automaticamente as bibliotecas necessárias ao `package.json`.

**Exemplo: Instalar `discord.js`**

```bash
npm install discord.js
```

Após instalar, seu `package.json` será automaticamente atualizado para incluir `discord.js` nas dependências:

{% code title="package.json" %}

```json
{
  "name": "discloud",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^14.0.3"
  }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.discloud.com/development-environment/supported-languages/javascript/package-json.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
