43

When running an NPM package with npx for the first time, it will display a prompt asking if you want to download the package.

For example, if you ran the command npx some-npm-package, you would receive the following prompt:

Need to install the following packages:
  some-npm-package
Ok to proceed? (y)

This is a problem if npx is being executed programmatically and you are unable to type input manually.

How can I automatically accept this prompt?

twiz
  • 9,041
  • 8
  • 52
  • 84

1 Answers1

80

npx has a --yes flag you can use to bypass the prompt:

npx --yes some-npm-package

This is undocumented if you run npx --help, but the documentation for this flag is hidden in the command's "description" on the NPM website.

There is also a --no flag available if you need to reject the prompt instead.

twiz
  • 9,041
  • 8
  • 52
  • 84