# NPM packages

<https://github.com/petalframework/petal_pro/commits/recipes/npm>

This recipe creates a `package.json` file and allows you to import NPM packages into your `app.js` file.

<figure><img src="/files/ikmmr7zoYqWED6jCtmlZ" alt=""><figcaption></figcaption></figure>

### How to use

**Note:** this has been rebased on the latest `main` branch and might not work properly on v1.3.0 and below. However, you should be able to work out how to apply it based on the diffs.

Follow the [cherry-pick instructions](/petal-pro-documentation/v1.3.0/recipes/how-to-apply-a-recipe-with-git-cherry-pick.md) with the branch `recipes/npm`.

Run `asdf install` to install the Node version mentioned in `.tool-versions`.

Run `npm install -g npm` to install NPM.

Run `mix setup` or `cd assets && npm install`.

Now when you run the server, it should all be working.

#### Add a new package

Here's how to install [tippy.js](https://atomiks.github.io/tippyjs/):

```
cd assets && npm i tippy.js
```

Then, in your `app.js`:

```javascript
import tippy from 'tippy.js';
```


---

# Agent Instructions: 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:

```
GET https://docs.petal.build/petal-pro-documentation/v1.3.0/recipes/npm-packages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
