95

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?

5 Answers 5

187

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.

2
28

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

1
  • 1
    Not if you're running a dependency. See the accepted answer. Commented Jan 23 at 23:12
7

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

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.

0

So, in short:

  • pnpx <pkg> # hot load remote package, and run.
  • pnpm <local_bin> # search & run executable in local node_modules/.

e.g:

  • pnpx @telegram-apps/create-mini-app@latest # create telegram mini app, via a remote package.
  • pnpm i -D @telegram-apps/mate # install a dev package to local, which contain executable mate.
  • pnpm mate -h # show help of the mate executable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.