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
-
what/who are you quoting in your question?
bun add
installs a dependency, and adds the it topackage.json
dependency list ...bun install
installs dependencies shown inpackage.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 useinstall
instead ofadd
it makesinstall
behave likeadd
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 asbun add packagename
(same asnpm
) - however,bun add
is the correct way to do it – Jaromanda X Commented Sep 29, 2023 at 10:16
3 Answers
Reset to default 6As 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条)