# How do I add dependencies to a managed Pkg package?

Company: Socra — Multiply Your Judgment
Canonical URL: https://support.socra.com/articles/art_01m46em65j6nex140xkp4t5wt4-manage-dependencies

Use Pkg's dependency commands to record another managed package in the same Account or an external npm package. A workspace dependency points to the target Package's identity. An npm dependency records the external name and version policy.

Pkg builds the managed package manifest from these records when it runs a Change or Release. Recording a dependency does not install it or prove that your code is compatible with it.

## Add a workspace dependency

Install the Account and Pkg CLI plugins and sign in to the Account containing both Packages. Replace `PACKAGE` with the consumer Package's name or `pkg_…` ID. Use the target Package's full name for `DEPENDENCY_NAME`:

```sh
socra pkg dependency add PACKAGE DEPENDENCY_NAME
```

The defaults are `workspace` for the source, `runtime` for the kind, and `*` for the version policy. The result includes a `pdep_…` dependency ID and the target Package ID. Keep the dependency ID for updates or removal.

Use the target's name. Although CLI help accepts a package ID for the target, that form can return `Package not found`. The target's name resolves within the same Account.

## Add an external npm dependency

Select the `npm` source explicitly. For example, this records version policy `^4` for `zod`:

```sh
socra pkg dependency add PACKAGE zod --source npm --specifier '^4'
```

Replace `PACKAGE` before running the command. Choose a version policy that works with your source.

## Inspect or change the dependency

List the Package's dependencies:

```sh
socra pkg dependency list PACKAGE
```

Follow the printed `--after` cursor if another page remains. Replace `DEPENDENCY_ID` below with the `pdep_…` ID of the edge you intend to change:

```sh
socra pkg dependency retrieve PACKAGE DEPENDENCY_ID
socra pkg dependency update PACKAGE DEPENDENCY_ID --kind development
```

The kinds are `runtime`, `development`, and `peer`. Pkg writes them to the manifest's `dependencies`, `devDependencies`, and `peerDependencies` fields, respectively. Use `--specifier` to change the version policy.

Retrieve the dependency again to confirm the saved kind and specifier. If a command fails after submission, inspect the dependency list before repeating it.

## Remove the dependency

Update source that uses the dependency, then remove its edge:

```sh
socra pkg dependency remove PACKAGE DEPENDENCY_ID
```

List dependencies again to confirm the result. Pkg prevents deletion of a target Package while a workspace dependency still points to it.

If a Change or Release reports the [storage-migration error](https://support.socra.com/articles/art_01m3zvnd1yzewn3tkw8qz5t3yv-change-storage-migration), dependency edits do not remove that restriction. Verify installation and code behavior when the managed execution path is available.

## Article details

- Collection: [Pkg](https://support.socra.com/collections/col_01m3z6vv74g6nshqaz3wpy8704-pkg)
- Canonical: https://support.socra.com/articles/art_01m46em65j6nex140xkp4t5wt4-manage-dependencies
