javascript - What is difference between bun install and bun add as mentioned in the bun official site? why bun add needed? - Sta

Running bun install will install dependencies mentioned in package.json file. At least package name nee

Running bun install will install dependencies mentioned in package.json file. At least package name needs to be included to bun add. But both adds a package to our project right, then why bun add needed? We can achieve the same things with bun install also right. Please clarify me

Running bun install will install dependencies mentioned in package.json file. At least package name needs to be included to bun add. But both adds a package to our project right, then why bun add needed? We can achieve the same things with bun install also right. Please clarify me

Share Improve this question edited Sep 29, 2023 at 9:05 C3roe 96.7k15 gold badges98 silver badges170 bronze badges asked Sep 29, 2023 at 8:59 Premchand KPremchand K 1492 silver badges8 bronze badges 8
  • what/who are you quoting in your question? bun add installs a dependency, and adds the it to package.json dependency list ... bun install installs dependencies shown in package.json dependency list... it's actually quite clearly documented – Jaromanda X Commented Sep 29, 2023 at 9:00
  • "why bun add needed?", for the reason it says. Packages are added with that mand. bun install won't add packages. – evolutionxbox Commented Sep 29, 2023 at 9:04
  • For example we don't have lodash currently in package.json. then bun install lodash is doing what? isn't it adding/installing lodash newly to package.json? – Premchand K Commented Sep 29, 2023 at 9:20
  • 1 perhaps bun has some undocumented feature where if you use install instead of add it makes install behave like add since install is documented without any additional arguments (ignoring "options" like --dry-run etc), and add is documented as requiring at least one – Jaromanda X Commented Sep 29, 2023 at 10:04
  • 2 @PremchandK - although it doesn't seem to be documented (haven't looked extensively) ... it does appear that bun install packagename works the same as bun add packagename (same as npm) - however, bun add is the correct way to do it – Jaromanda X Commented Sep 29, 2023 at 10:16
 |  Show 3 more ments

3 Answers 3

Reset to default 6

As per my understanding, The key difference betweenbun install and bun add is that running bun install without a package name checks package.json and install all packages automatically and with bun add, it cannot automatically check and install all dependencies in package.json. And at least need to be added package name is required to run bun add.

And what we do with bun add can be done with bun install as well. It is just a personal preference whether to use bun i or bun add.

Here’s your answer https://github./oven-sh/bun/discussions/2727

The mands bun install and bun add are essentially the same in terms of their basic functionality, which is to add a package to your project. The bun add mand was introduced first and was inspired by similar mands in other package managers like Yarn v1. The similarity in functionality between bun install and bun add means you can use either to add packages to your project. However, bun add might be more familiar to users ing from other package managers like Yarn because of its naming convention and usage pattern.

While both mands can manage packages, bun add is convenient because it not only installs the package but also updates package.json. My preference is to simply use bun i, which bines both actions, making it easy to add and track dependencies.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744366987a4570753.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信