# A file imports a package that isn't declared

What "imports …, which package.json doesn't declare" means and how to fix it.

```text
error: packages/ui/src/date.ts:1 imports date-fns, which packages/ui/package.json doesn't declare
hint: Add date-fns to the dependencies in packages/ui/package.json, for example with pnpm add date-fns --filter ui, so it doesn't rely on another package's.
```

## Why it happens

[`axle boundaries`](https://axlers.dev/docs/reference/boundaries.md) found a file importing a package that neither its own `package.json` nor the root's lists in `dependencies`, `devDependencies`, `peerDependencies` or `optionalDependencies`. It usually works because another package depends on it and the package manager put it where Node.js finds it, so it breaks when that package changes or the package manager lays things out differently. Axle also doesn't know the package uses it, so a change to it may not rebuild what it should.

## How to fix it

Add the package to the `package.json` the hint names, in `dependencies`, or `devDependencies` for tests and tools, then install. Each package is reported once for each package that imports it, at the first file that does, so check its other files too. If the import is a path alias that looks like a package's name, such as `src/utils` or `@app/utils`, add it to `ignoreImports` under `[boundaries]` in `axle.toml`, such as `ignoreImports = ["src/*"]`.
