# Packages

Search npm, add packages to your project, update them to their latest release, and remove the ones you no longer need.

The **Packages** view searches the npm registry and installs a package in your project in one click. It also lists what your project already uses, shows which packages have a newer release, and lets you update or remove them.

The Packages view with the Updates list, where each row shows the installed and the latest version and major releases are marked, above the Dependencies list.

## What you can do

- Search npm packages by name.
- See the latest version and weekly downloads of each result.
- Install a package in one click.
- See your **Dependencies** and **Dev dependencies** with their versions.
- See which packages have a newer release, and update them in one click.
- Remove a package.
- Run the scripts of your `package.json`, each in its own terminal.

## Add a package

1. ### Open Packages

   In **Code** mode, choose **Packages** in the views rail. You can also run **Packages** from the command palette (`Cmd/Ctrl + K`).
2. ### Search

   Type in **Search npm packages...**. Results come from the npm registry. Packages you already have are marked **Installed**.
3. ### Install

   Click a result. Lyna installs it in your sandbox and shows a message when the package is installed. It is added to `package.json` as a dependency.

## Update a package

When a newer release of a package you use exists, Packages lists it under **Updates**, with the version you have and the latest one. A **Major** label marks a release that can change how the package works: read its release notes before you update.

Choose the update button of a package. Lyna installs the latest release in your sandbox and updates `package.json`. A dev dependency stays a dev dependency. Updates run one at a time.

Packages that point to a local folder or a tag, and prereleases you picked on purpose, never show an update.

## Remove a package

Find the package under **Dependencies** or **Dev dependencies** and choose its remove button. Lyna uninstalls it and updates `package.json`.

> [!NOTE]
>
> **The sandbox must be ready**
>
> Installs and removals run in your sandbox. If you see **Sandbox not ready**, wait for the project to finish loading, then try again.

> [!WARNING]
>
> **Check the code that uses it**
>
> Removing a package does not change the files that import it. Remove those imports too, or the app shows a build error. See [Problems](/features/test-and-debug/problems).

## Run a script

The **Scripts** section lists the scripts of your `package.json`, such as `dev`, `build` or `preview`. It follows the file: a script you add, rename or remove shows in the list as soon as `package.json` is saved, whether you edit it in the code editor, Lyna AI changes it, or a command in the Terminal does. Add `"typecheck": "tsc --noEmit"` or `"format:check": "prettier --check ."` and it is one click away. Choose the run button of a script: a terminal named after it opens and runs `bun run <name>`. While it runs, the row shows **Running** and a stop button, which stops the script as `Ctrl + C` does. Closing that terminal stops it too.

The `dev` script is your project's dev server, the one behind your preview. Its row shows **Preview** while the server runs, and its restart button restarts that server and brings its log forward in the Terminal. It never starts a second server.

A script whose name uses other characters than letters, digits and `:` `.` `_` `-` cannot run from here: run it in the [Terminal](/features/code/terminal).

## Other ways to add packages

- Ask the AI in the chat, for example "Add a date picker with date-fns". The AI installs what it needs.
- Run `bun add <name>` in the [Terminal](/features/code/terminal). Use `bun add -d <name>` for a dev dependency.
- UI components from the **Components** panel install their own files and dependencies. See [Components](/features/design/components).

## FAQ

### How do I update a package?

Open **Packages**: a package with a newer release is listed under **Updates**, with its update button. You can also ask the AI to update it.

### Can I use any npm package?

Any package that runs in the browser in a React app. Packages written only for a server, such as database drivers, do not run in your app's pages.

## Related

- [Terminal](/features/code/terminal): Run commands in your sandbox.
- [Components](/features/design/components): Add ready-made UI components.
- [Environment variables](/features/code/environment-variables): Add the keys a package needs.
