DEV Community

Cover image for Execute commands using your project dependencies
Alexandre Nédélec
Alexandre Nédélec

Posted on • Originally published at bordeauxcoders.com

Execute commands using your project dependencies

You have a dependency in your project and want to execute a command using it? The pnpm exec command can help you with that.

An example

 pnpm exec eslint . --ext .ts
Enter fullscreen mode Exit fullscreen mode

Given that ESLint is a project dependency, this example shows how to use the pnpm exec command to run the ESLint tool on all TypeScript files within the project.

Some use cases

  • You need to do a specific command that is not part of your npm scripts

  • You want to execute a tool that is a dependency of your project without having to install it globally

  • You need to execute a CLI package command in a CI pipeline, and this package is already included in the devDependencies of your project.

Good to know

If the command you are using does not conflict with a built-in pnpm command, there is no need to specify 'exec'. Referring to the previous example, you can simply run:

 pnpm eslint . --ext .ts
Enter fullscreen mode Exit fullscreen mode

It's one of the small details that make using pnpm so pleasant.

Top comments (0)