33

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?

Matt Sanders
  • 8,023
  • 3
  • 37
  • 49

3 Answers3

64

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.

Matt Sanders
  • 8,023
  • 3
  • 37
  • 49
4

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.

cachius
  • 1,743
  • 1
  • 8
  • 21
1

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