Can I use npx with pnpm?
Asked Answered
P

4

75

Can I use npx together with a pnpm install?

It doesn't seem to work and pnpx fetches remote dependencies, it seems more like npm create.

Is there a way to use npx with pnpm to execute local binaries or is there a different pnpm equivalent?

Porras answered 10/2, 2023 at 15:54 Comment(0)
P
154

The are are two key uses of npx.

Running executables inside your downloaded dependencies

For example npx jest.

The pnpm equivalent is pnpm exec jest.

Running executable commands in packages you want to download transiently

For example npx create-react-app my-app.

The pnpm equivalent of this is pnpm dlx create-react-app my-app.

Note: There used to be a pnpx command, but it has been deprecated.

Porras answered 20/2, 2023 at 18:36 Comment(1)
FYI you can use pnpm jest if you like typing lessJanayjanaya
S
21

Based on PNPM Feature Comparison the alternative to NPX in PNPM should pnpm dlx

Submissive answered 18/8, 2023 at 7:40 Comment(1)
Not if you're running a dependency. See the accepted answer.Propound
A
5

Comment from the addition of dlx:

npx is also kind of deprecated and replaced by npm exec.

Which probably refers to npx being deprecated as standalone package and inclusion into npm itself by use of npm exec . The main difference is now that

npm exec supports -- to end argument parsing for itself and count following args to the package to be run.

Whereas npx requires all args to itself to be given before the package to be run and couts all following arguments to the latter.

Adalbert answered 31/5, 2023 at 8:3 Comment(0)
L
4

Short answer yes. npx create-next-app@latest --use-pnpm

Lavona answered 7/11, 2023 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.