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

1

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.

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay