# Getting Started with Pnpm: Fundamental Commands

As developers, we are constantly looking for tools that can help us to improve our daily work and our productivity. With web projects, package management has been for a long time associated with npm. However, a newer contender, pnpm, offers many benefits that make it worth considering. In this article, we will explore the basic commands of pnpm.

## Initializing a new project

```bash
pnpm init
```

[This command](https://pnpm.io/cli/init) creates a `package.json` file where each of the project's dependencies and scripts will be referenced.

## Adding a package

```bash
pnpm add <package-name>
```

[This command](https://pnpm.io/cli/add) simply adds a new package to your project.

One of the main pnpm's benefits over npm or yarn is its disk space efficiency. While npm installs each package separately for every project, pnpm uses a different [approach](https://pnpm.io/motivation): packages are stored in a central location on the disk and shared across projects, resulting in significant disk space savings and faster installations.

## Installing all dependencies

```bash
pnpm install
```

Run [this command](https://pnpm.io/cli/install) to install all dependencies for a project.

## Updating packages

```bash
pnpm update <package-name>
```

Just like any package manager, [this command](https://pnpm.io/cli/update) allows you to specify a specific package version to update or update all packages in your project. With pnpm's shared store, updating packages becomes faster, as it can reuse packages already present on the disk.

## Removing packages

```bash
pnpm remove <package-name>
```

To remove a package from your project, just run [this command](https://pnpm.io/cli/remove) and specify the name of the package to be removed. Note that if you don't specify the `-g` option, your package will remain on your disk, ready to be reused within another project.

## Running scripts

```bash
pnpm run <script-name>
pnpm <script-name>
```

Defining scripts within the `package.json` file allows you to have aliases that are easier to manipulate than excessively long CLI commands. You can run them by using [the `run` command](https://pnpm.io/cli/run) and the name of the script. One cool thing is that you can save a few keystrokes by omitting the `run` keyword, pnpm will automatically look for script aliases.
