# `NPM.Package.JSON`
[🔗](https://github.com/elixir-volt/npm_ex/blob/v0.7.4/lib/npm/package/json.ex#L1)

Read and write `package.json` files.

# `add_dep`

```elixir
@spec add_dep(String.t(), String.t(), String.t(), keyword()) :: :ok | {:error, term()}
```

Add a dependency to `package.json`, creating the file if needed.

## Options

  * `:dev` - when `true`, adds to `devDependencies` instead of `dependencies`

# `expand_workspaces`

```elixir
@spec expand_workspaces([String.t()], String.t()) :: [String.t()]
```

Expand workspace patterns to actual directories with package.json files.

Supports glob patterns like `packages/*` and `apps/**`.

# `file_dep?`

```elixir
@spec file_dep?(String.t()) :: boolean()
```

Check if a dependency range refers to a local file path.

Supports `file:../path` and `file:./path` references.

# `git_dep?`

```elixir
@spec git_dep?(String.t()) :: boolean()
```

Check if a dependency range refers to a git repository.

Supports `git+https://`, `git+ssh://`, `github:user/repo`, and `git://` URLs.

# `read`

```elixir
@spec read(String.t()) ::
  {:ok, %{required(String.t()) =&gt; String.t()}} | {:error, term()}
```

Read dependencies from `package.json`.

# `read_all`

```elixir
@spec read_all(String.t()) ::
  {:ok,
   %{dependencies: map(), dev_dependencies: map(), optional_dependencies: map()}}
  | {:error, term()}
```

Read all dependency groups from `package.json`.

# `read_bundle_deps`

```elixir
@spec read_bundle_deps(String.t()) :: {:ok, [String.t()]} | {:error, term()}
```

Read bundleDependencies (or bundledDependencies) from `package.json`.

Returns a list of package names that should be bundled in the tarball.

# `read_overrides`

```elixir
@spec read_overrides(String.t()) ::
  {:ok, %{required(String.t()) =&gt; String.t()}} | {:error, term()}
```

Read overrides from `package.json`.

# `read_resolutions`

```elixir
@spec read_resolutions(String.t()) ::
  {:ok, %{required(String.t()) =&gt; String.t()}} | {:error, term()}
```

Read resolutions (Yarn-style) from `package.json`.

# `read_scripts`

```elixir
@spec read_scripts(String.t()) ::
  {:ok, %{required(String.t()) =&gt; String.t()}} | {:error, term()}
```

Read scripts from `package.json`.

# `read_workspaces`

```elixir
@spec read_workspaces(String.t()) :: {:ok, [String.t()]} | {:error, term()}
```

Read workspace patterns from `package.json`.

# `remove_dep`

```elixir
@spec remove_dep(String.t(), String.t()) :: :ok | {:error, term()}
```

Remove a dependency from `package.json`.

# `resolve_file_dep`

```elixir
@spec resolve_file_dep(String.t(), String.t()) :: String.t()
```

Resolve a file dependency path.

Returns the absolute path for a `file:` reference.

# `url_dep?`

```elixir
@spec url_dep?(String.t()) :: boolean()
```

Check if a dependency range refers to a URL tarball.

Supports `http://` and `https://` URLs ending in `.tgz` or `.tar.gz`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
