new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Bun · Package manager · all subjects

add

13 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

bun add basic usage

To add a package to your project, use `bun add package-name`. For example, `bun add preact` adds the preact package.

bun add with version specification

You can specify a version, version range, or tag when adding a package. Examples: `bun add zod@3.20.0` for a specific version, `bun add zod@^3.0.0` for a version range, and `bun add zod@latest` for the latest tag.

bun add --dev flag

The `--dev` flag adds a package as a dev dependency to `"devDependencies"` in package.json. Aliases are `--development`, `-d`, and `-D`. Example: `bun add --dev @types/react` or `bun add -d @types/react`.

bun add --optional flag

The `--optional` flag adds a package as an optional dependency to `"optionalDependencies"` in package.json. Example: `bun add --optional lodash`.

bun add --peer flag

The `--peer` flag adds a package as a peer dependency to `"peerDependencies"` in package.json. Example: `bun add --peer @types/bun`.

bun add --exact flag pins exact version

The `--exact` flag (alias `-E`) pins a package to the resolved version by writing the exact version number to package.json instead of a version range. For example, `bun add react --exact` or `bun add react -E` writes `"react": "18.2.0"` instead of `"react": "^18.2.0"`.

bun add --global flag for global installation

The `--global` flag (aliases: `-g`, `bun install --global`, `bun install -g`) installs a package globally without modifying the package.json of the current project. This is used for installing command-line tools. Example: `bun add --global cowsay` or `bun add -g cowsay`.

Global installation configuration in bunfig.toml

Global installation behavior can be configured in bunfig.toml using the `[install]` section with two properties: `globalDir` specifies where packages are installed (default `~/.bun/install/global`), and `globalBinDir` specifies where globally-installed package bins are linked (default `~/.bun/bin`).

Bun does not execute arbitrary lifecycle scripts by default

Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall`, as these represent a potential security risk.

bun add from git repository

To add a dependency from a public or private git repository, use `bun add` with a git URL. Example: `bun add git@github.com:moment/moment.git`. For private repositories, your system needs appropriate SSH credentials.

Git protocols supported by bun add

Bun supports multiple git protocols for dependencies: `github`, `git`, `git+ssh`, and `git+https`. Examples in package.json: `"dayjs": "git+https://github.com/iamkun/dayjs.git"`, `"lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21"`, `"moment": "git@github.com:moment/moment.git"`, and `"zod": "github:colinhacks/zod"`.

bun add tarball dependencies

A package can correspond to a publicly hosted .tgz file URL. Bun downloads and installs the package from the tarball URL instead of from the package registry. Example: `bun add zod@https://registry.npmjs.org/zod/-/zod-3.21.4.tgz` writes the URL to package.json as the dependency.

Install a security scanner with bun add

Install a security scanner from npm using bun add -d with the scanner package name, for example: bun add -d @oven/bun-security-scanner

Give your agent this brain