Automatically accept installing NPX package [duplicate]
Asked Answered
P

1

71

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?

Patrilineal answered 17/1, 2022 at 14:28 Comment(0)
P
130

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.

Patrilineal answered 17/1, 2022 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.