bun-types 1.1.37-canary.20241123T140655 → 1.1.37-canary.20241125T140601

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/docs/api/binary-data.md +1028 -0
  2. package/docs/api/cc.md +197 -0
  3. package/docs/api/color.md +262 -0
  4. package/docs/api/console.md +38 -0
  5. package/docs/api/dns.md +113 -0
  6. package/docs/api/fetch.md +308 -0
  7. package/docs/api/ffi.md +536 -0
  8. package/docs/api/file-io.md +358 -0
  9. package/docs/api/file-system-router.md +112 -0
  10. package/docs/api/file.md +19 -0
  11. package/docs/api/glob.md +157 -0
  12. package/docs/api/globals.md +387 -0
  13. package/docs/api/hashing.md +314 -0
  14. package/docs/api/html-rewriter.md +31 -0
  15. package/docs/api/http.md +661 -0
  16. package/docs/api/import-meta.md +69 -0
  17. package/docs/api/node-api.md +16 -0
  18. package/docs/api/semver.md +52 -0
  19. package/docs/api/spawn.md +441 -0
  20. package/docs/api/sqlite.md +692 -0
  21. package/docs/api/streams.md +214 -0
  22. package/docs/api/tcp.md +221 -0
  23. package/docs/api/test.md +1 -0
  24. package/docs/api/transpiler.md +274 -0
  25. package/docs/api/udp.md +125 -0
  26. package/docs/api/utils.md +773 -0
  27. package/docs/api/websockets.md +547 -0
  28. package/docs/api/workers.md +230 -0
  29. package/docs/benchmarks.md +120 -0
  30. package/docs/bun-flavored-toml.md +42 -0
  31. package/docs/bundler/executables.md +291 -0
  32. package/docs/bundler/index.md +1543 -0
  33. package/docs/bundler/intro.md +75 -0
  34. package/docs/bundler/loaders.md +288 -0
  35. package/docs/bundler/macros.md +327 -0
  36. package/docs/bundler/plugins.md +30 -0
  37. package/docs/bundler/vs-esbuild.md +1127 -0
  38. package/docs/cli/add.md +163 -0
  39. package/docs/cli/bun-completions.md +3 -0
  40. package/docs/cli/bun-create.md +254 -0
  41. package/docs/cli/bun-dev.md +21 -0
  42. package/docs/cli/bun-install.md +255 -0
  43. package/docs/cli/bun-upgrade.md +39 -0
  44. package/docs/cli/bunx.md +80 -0
  45. package/docs/cli/filter.md +57 -0
  46. package/docs/cli/init.md +40 -0
  47. package/docs/cli/install.md +205 -0
  48. package/docs/cli/link.md +38 -0
  49. package/docs/cli/outdated.md +61 -0
  50. package/docs/cli/patch-commit.md +9 -0
  51. package/docs/cli/pm.md +150 -0
  52. package/docs/cli/publish.md +107 -0
  53. package/docs/cli/remove.md +5 -0
  54. package/docs/cli/run.md +196 -0
  55. package/docs/cli/test.md +247 -0
  56. package/docs/cli/unlink.md +7 -0
  57. package/docs/cli/update.md +34 -0
  58. package/docs/contributing/upgrading-webkit.md +57 -0
  59. package/docs/ecosystem/elysia.md +24 -0
  60. package/docs/ecosystem/express.md +37 -0
  61. package/docs/ecosystem/hono.md +18 -0
  62. package/docs/ecosystem/react.md +65 -0
  63. package/docs/ecosystem/stric.md +37 -0
  64. package/docs/guides/binary/arraybuffer-to-array.md +27 -0
  65. package/docs/guides/binary/arraybuffer-to-blob.md +24 -0
  66. package/docs/guides/binary/arraybuffer-to-buffer.md +25 -0
  67. package/docs/guides/binary/arraybuffer-to-string.md +15 -0
  68. package/docs/guides/binary/arraybuffer-to-typedarray.md +39 -0
  69. package/docs/guides/binary/blob-to-arraybuffer.md +14 -0
  70. package/docs/guides/binary/blob-to-dataview.md +14 -0
  71. package/docs/guides/binary/blob-to-stream.md +14 -0
  72. package/docs/guides/binary/blob-to-string.md +15 -0
  73. package/docs/guides/binary/blob-to-typedarray.md +14 -0
  74. package/docs/guides/binary/buffer-to-arraybuffer.md +14 -0
  75. package/docs/guides/binary/buffer-to-blob.md +14 -0
  76. package/docs/guides/binary/buffer-to-readablestream.md +41 -0
  77. package/docs/guides/binary/buffer-to-string.md +25 -0
  78. package/docs/guides/binary/buffer-to-typedarray.md +14 -0
  79. package/docs/guides/binary/dataview-to-string.md +15 -0
  80. package/docs/guides/binary/typedarray-to-arraybuffer.md +25 -0
  81. package/docs/guides/binary/typedarray-to-blob.md +16 -0
  82. package/docs/guides/binary/typedarray-to-buffer.md +14 -0
  83. package/docs/guides/binary/typedarray-to-dataview.md +14 -0
  84. package/docs/guides/binary/typedarray-to-readablestream.md +41 -0
  85. package/docs/guides/binary/typedarray-to-string.md +16 -0
  86. package/docs/guides/ecosystem/astro.md +72 -0
  87. package/docs/guides/ecosystem/discordjs.md +77 -0
  88. package/docs/guides/ecosystem/docker.md +140 -0
  89. package/docs/guides/ecosystem/drizzle.md +185 -0
  90. package/docs/guides/ecosystem/edgedb.md +228 -0
  91. package/docs/guides/ecosystem/elysia.md +31 -0
  92. package/docs/guides/ecosystem/express.md +40 -0
  93. package/docs/guides/ecosystem/hono.md +39 -0
  94. package/docs/guides/ecosystem/mongoose.md +87 -0
  95. package/docs/guides/ecosystem/neon-drizzle.md +220 -0
  96. package/docs/guides/ecosystem/neon-serverless-postgres.md +55 -0
  97. package/docs/guides/ecosystem/nextjs.md +38 -0
  98. package/docs/guides/ecosystem/nuxt.md +56 -0
  99. package/docs/guides/ecosystem/pm2.md +57 -0
  100. package/docs/guides/ecosystem/prisma.md +140 -0
  101. package/docs/guides/ecosystem/qwik.md +107 -0
  102. package/docs/guides/ecosystem/react.md +49 -0
  103. package/docs/guides/ecosystem/remix.md +78 -0
  104. package/docs/guides/ecosystem/render.md +79 -0
  105. package/docs/guides/ecosystem/sentry.md +52 -0
  106. package/docs/guides/ecosystem/solidstart.md +58 -0
  107. package/docs/guides/ecosystem/ssr-react.md +51 -0
  108. package/docs/guides/ecosystem/stric.md +55 -0
  109. package/docs/guides/ecosystem/sveltekit.md +125 -0
  110. package/docs/guides/ecosystem/systemd.md +113 -0
  111. package/docs/guides/ecosystem/vite.md +70 -0
  112. package/docs/guides/http/cluster.md +66 -0
  113. package/docs/guides/http/fetch-unix.md +33 -0
  114. package/docs/guides/http/fetch.md +24 -0
  115. package/docs/guides/http/file-uploads.md +94 -0
  116. package/docs/guides/http/hot.md +22 -0
  117. package/docs/guides/http/proxy.md +24 -0
  118. package/docs/guides/http/server.md +46 -0
  119. package/docs/guides/http/simple.md +18 -0
  120. package/docs/guides/http/stream-file.md +48 -0
  121. package/docs/guides/http/stream-iterator.md +47 -0
  122. package/docs/guides/http/stream-node-streams-in-bun.md +20 -0
  123. package/docs/guides/http/tls.md +30 -0
  124. package/docs/guides/install/add-dev.md +26 -0
  125. package/docs/guides/install/add-git.md +36 -0
  126. package/docs/guides/install/add-optional.md +25 -0
  127. package/docs/guides/install/add-peer.md +17 -0
  128. package/docs/guides/install/add-tarball.md +33 -0
  129. package/docs/guides/install/add.md +42 -0
  130. package/docs/guides/install/azure-artifacts.md +73 -0
  131. package/docs/guides/install/cicd.md +41 -0
  132. package/docs/guides/install/custom-registry.md +30 -0
  133. package/docs/guides/install/from-npm-install-to-bun-install.md +214 -0
  134. package/docs/guides/install/git-diff-bun-lockfile.md +38 -0
  135. package/docs/guides/install/jfrog-artifactory.md +28 -0
  136. package/docs/guides/install/npm-alias.md +23 -0
  137. package/docs/guides/install/registry-scope.md +36 -0
  138. package/docs/guides/install/trusted.md +48 -0
  139. package/docs/guides/install/workspaces.md +70 -0
  140. package/docs/guides/install/yarnlock.md +42 -0
  141. package/docs/guides/process/argv.md +57 -0
  142. package/docs/guides/process/ctrl-c.md +16 -0
  143. package/docs/guides/process/ipc.md +66 -0
  144. package/docs/guides/process/nanoseconds.md +13 -0
  145. package/docs/guides/process/os-signals.md +39 -0
  146. package/docs/guides/process/spawn-stderr.md +31 -0
  147. package/docs/guides/process/spawn-stdout.md +26 -0
  148. package/docs/guides/process/spawn.md +41 -0
  149. package/docs/guides/process/stdin.md +54 -0
  150. package/docs/guides/read-file/arraybuffer.md +28 -0
  151. package/docs/guides/read-file/buffer.md +19 -0
  152. package/docs/guides/read-file/exists.md +16 -0
  153. package/docs/guides/read-file/json.md +17 -0
  154. package/docs/guides/read-file/mime.md +20 -0
  155. package/docs/guides/read-file/stream.md +26 -0
  156. package/docs/guides/read-file/string.md +22 -0
  157. package/docs/guides/read-file/uint8array.md +21 -0
  158. package/docs/guides/read-file/watch.md +68 -0
  159. package/docs/guides/runtime/cicd.md +43 -0
  160. package/docs/guides/runtime/define-constant.md +145 -0
  161. package/docs/guides/runtime/import-html.md +15 -0
  162. package/docs/guides/runtime/import-json.md +44 -0
  163. package/docs/guides/runtime/import-toml.md +30 -0
  164. package/docs/guides/runtime/read-env.md +32 -0
  165. package/docs/guides/runtime/set-env.md +37 -0
  166. package/docs/guides/runtime/shell.md +40 -0
  167. package/docs/guides/runtime/timezone.md +35 -0
  168. package/docs/guides/runtime/tsconfig-paths.md +29 -0
  169. package/docs/guides/runtime/typescript.md +47 -0
  170. package/docs/guides/runtime/vscode-debugger.md +47 -0
  171. package/docs/guides/runtime/web-debugger.md +82 -0
  172. package/docs/guides/streams/node-readable-to-arraybuffer.md +11 -0
  173. package/docs/guides/streams/node-readable-to-blob.md +11 -0
  174. package/docs/guides/streams/node-readable-to-json.md +12 -0
  175. package/docs/guides/streams/node-readable-to-string.md +12 -0
  176. package/docs/guides/streams/node-readable-to-uint8array.md +11 -0
  177. package/docs/guides/streams/to-array.md +14 -0
  178. package/docs/guides/streams/to-arraybuffer.md +14 -0
  179. package/docs/guides/streams/to-blob.md +14 -0
  180. package/docs/guides/streams/to-buffer.md +15 -0
  181. package/docs/guides/streams/to-json.md +14 -0
  182. package/docs/guides/streams/to-string.md +14 -0
  183. package/docs/guides/streams/to-typedarray.md +22 -0
  184. package/docs/guides/test/bail.md +22 -0
  185. package/docs/guides/test/coverage-threshold.md +60 -0
  186. package/docs/guides/test/coverage.md +44 -0
  187. package/docs/guides/test/happy-dom.md +68 -0
  188. package/docs/guides/test/migrate-from-jest.md +110 -0
  189. package/docs/guides/test/mock-clock.md +48 -0
  190. package/docs/guides/test/mock-functions.md +68 -0
  191. package/docs/guides/test/rerun-each.md +14 -0
  192. package/docs/guides/test/run-tests.md +111 -0
  193. package/docs/guides/test/skip-tests.md +39 -0
  194. package/docs/guides/test/snapshot.md +99 -0
  195. package/docs/guides/test/spy-on.md +46 -0
  196. package/docs/guides/test/testing-library.md +87 -0
  197. package/docs/guides/test/timeout.md +15 -0
  198. package/docs/guides/test/todo-tests.md +67 -0
  199. package/docs/guides/test/update-snapshots.md +50 -0
  200. package/docs/guides/test/watch-mode.md +19 -0
  201. package/docs/guides/util/base64.md +15 -0
  202. package/docs/guides/util/deep-equals.md +39 -0
  203. package/docs/guides/util/deflate.md +18 -0
  204. package/docs/guides/util/detect-bun.md +23 -0
  205. package/docs/guides/util/entrypoint.md +17 -0
  206. package/docs/guides/util/escape-html.md +22 -0
  207. package/docs/guides/util/file-url-to-path.md +14 -0
  208. package/docs/guides/util/gzip.md +18 -0
  209. package/docs/guides/util/hash-a-password.md +54 -0
  210. package/docs/guides/util/import-meta-dir.md +13 -0
  211. package/docs/guides/util/import-meta-file.md +13 -0
  212. package/docs/guides/util/import-meta-path.md +13 -0
  213. package/docs/guides/util/main.md +32 -0
  214. package/docs/guides/util/path-to-file-url.md +14 -0
  215. package/docs/guides/util/sleep.md +22 -0
  216. package/docs/guides/util/version.md +21 -0
  217. package/docs/guides/util/which-path-to-executable-bin.md +15 -0
  218. package/docs/guides/websocket/compression.md +31 -0
  219. package/docs/guides/websocket/context.md +72 -0
  220. package/docs/guides/websocket/pubsub.md +38 -0
  221. package/docs/guides/websocket/simple.md +33 -0
  222. package/docs/guides/write-file/append.md +52 -0
  223. package/docs/guides/write-file/basic.md +44 -0
  224. package/docs/guides/write-file/blob.md +28 -0
  225. package/docs/guides/write-file/cat.md +17 -0
  226. package/docs/guides/write-file/file-cp.md +16 -0
  227. package/docs/guides/write-file/filesink.md +52 -0
  228. package/docs/guides/write-file/response.md +17 -0
  229. package/docs/guides/write-file/stdout.md +21 -0
  230. package/docs/guides/write-file/stream.md +17 -0
  231. package/docs/guides/write-file/unlink.md +23 -0
  232. package/docs/index.md +77 -0
  233. package/docs/install/cache.md +57 -0
  234. package/docs/install/index.md +202 -0
  235. package/docs/install/lifecycle.md +46 -0
  236. package/docs/install/lockfile.md +90 -0
  237. package/docs/install/npmrc.md +75 -0
  238. package/docs/install/overrides.md +73 -0
  239. package/docs/install/patch.md +57 -0
  240. package/docs/install/registries.md +30 -0
  241. package/docs/install/workspaces.md +70 -0
  242. package/docs/installation.md +289 -0
  243. package/docs/project/benchmarking.md +203 -0
  244. package/docs/project/building-windows.md +162 -0
  245. package/docs/project/internals/build-process-for-ci.md +75 -0
  246. package/docs/project/roadmap.md +87 -0
  247. package/docs/quickstart.md +144 -0
  248. package/docs/runtime/autoimport.md +94 -0
  249. package/docs/runtime/bun-apis.md +129 -0
  250. package/docs/runtime/bunfig.md +532 -0
  251. package/docs/runtime/debugger.md +325 -0
  252. package/docs/runtime/env.md +214 -0
  253. package/docs/runtime/hot.md +139 -0
  254. package/docs/runtime/index.md +309 -0
  255. package/docs/runtime/jsx.md +326 -0
  256. package/docs/runtime/loaders.md +127 -0
  257. package/docs/runtime/modules.md +298 -0
  258. package/docs/runtime/nodejs-apis.md +456 -0
  259. package/docs/runtime/plugins.md +605 -0
  260. package/docs/runtime/shell.md +537 -0
  261. package/docs/runtime/typescript.md +60 -0
  262. package/docs/runtime/web-apis.md +128 -0
  263. package/docs/test/coverage.md +91 -0
  264. package/docs/test/dom.md +75 -0
  265. package/docs/test/hot.md +15 -0
  266. package/docs/test/lifecycle.md +81 -0
  267. package/docs/test/mocks.md +236 -0
  268. package/docs/test/snapshots.md +15 -0
  269. package/docs/test/time.md +106 -0
  270. package/docs/test/writing.md +547 -0
  271. package/docs/typescript.md +51 -0
  272. package/package.json +5 -4
@@ -0,0 +1,75 @@
1
+ Bun supports loading configuration options from [`.npmrc`](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc) files, allowing you to reuse existing registry/scope configurations.
2
+
3
+ {% callout %}
4
+
5
+ **NOTE**: We recommend migrating your `.npmrc` file to Bun's [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig) format, as it provides more flexible options and can let you configure Bun-specific options.
6
+
7
+ {% /callout %}
8
+
9
+ # Supported options
10
+
11
+ ### `registry`: Set the default registry
12
+
13
+ The default registry is used to resolve packages, it's default value is `npm`'s official registry (`https://registry.npmjs.org/`).
14
+
15
+ To change it, you can set the `registry` option in `.npmrc`:
16
+
17
+ ```ini
18
+ registry=http://localhost:4873/
19
+ ```
20
+
21
+ The equivalent `bunfig.toml` option is [`install.registry`](https://bun.sh/docs/runtime/bunfig#install-registry):
22
+
23
+ ```toml
24
+ install.registry = "http://localhost:4873/"
25
+ ```
26
+
27
+ ### `@<scope>:registry`: Set the registry for a specific scope
28
+
29
+ Allows you to set the registry for a specific scope:
30
+
31
+ ```ini
32
+ @myorg:registry=http://localhost:4873/
33
+ ```
34
+
35
+ The equivalent `bunfig.toml` option is to add a key in [`install.scopes`](https://bun.sh/docs/runtime/bunfig#install-registry):
36
+
37
+ ```toml
38
+ [install.scopes]
39
+ myorg = "http://localhost:4873/"
40
+ ```
41
+
42
+ ### `//<registry_url>/:<key>=<value>`: Configure options for a specific registry
43
+
44
+ Allows you to set options for a specific registry:
45
+
46
+ ```ini
47
+ # set an auth token for the registry
48
+ # ${...} is a placeholder for environment variables
49
+ //http://localhost:4873/:_authToken=${NPM_TOKEN}
50
+
51
+
52
+ # or you could set a username and password
53
+ # note that the password is base64 encoded
54
+ //http://localhost:4873/:username=myusername
55
+
56
+ //http://localhost:4873/:_password=${NPM_PASSWORD}
57
+
58
+ # or use _auth, which is your username and password
59
+ # combined into a single string, which is then base 64 encoded
60
+ //http://localhost:4873/:_auth=${NPM_AUTH}
61
+ ```
62
+
63
+ The following options are supported:
64
+
65
+ - `_authToken`
66
+ - `username`
67
+ - `_password` (base64 encoded password)
68
+ - `_auth` (base64 encoded username:password, e.g. `btoa(username + ":" + password)`)
69
+
70
+ The equivalent `bunfig.toml` option is to add a key in [`install.scopes`](https://bun.sh/docs/runtime/bunfig#install-registry):
71
+
72
+ ```toml
73
+ [install.scopes]
74
+ myorg = { url = "http://localhost:4873/", username = "myusername", password = "$NPM_PASSWORD" }
75
+ ```
@@ -0,0 +1,73 @@
1
+ Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_—the dependencies of your dependencies.
2
+
3
+ ```json-diff#package.json
4
+ {
5
+ "name": "my-app",
6
+ "dependencies": {
7
+ "foo": "^2.0.0"
8
+ },
9
+ + "overrides": {
10
+ + "bar": "~4.4.0"
11
+ + }
12
+ }
13
+ ```
14
+
15
+ By default, Bun will install the latest version of all dependencies and metadependencies, according to the ranges specified in each package's `package.json`. Let's say you have a project with one dependency, `foo`, which in turn has a dependency on `bar`. This means `bar` is a _metadependency_ of our project.
16
+
17
+ ```json#package.json
18
+ {
19
+ "name": "my-app",
20
+ "dependencies": {
21
+ "foo": "^2.0.0"
22
+ }
23
+ }
24
+ ```
25
+
26
+ When you run `bun install`, Bun will install the latest versions of each package.
27
+
28
+ ```
29
+ # tree layout of node_modules
30
+ node_modules
31
+ ├── foo@1.2.3
32
+ └── bar@4.5.6
33
+ ```
34
+
35
+ But what if a security vulnerability was introduced in `bar@4.5.6`? We may want a way to pin `bar` to an older version that doesn't have the vulnerability. This is where `"overrides"`/`"resolutions"` come in.
36
+
37
+ ## `"overrides"`
38
+
39
+ Add `bar` to the `"overrides"` field in `package.json`. Bun will defer to the specified version range when determining which version of `bar` to install, whether it's a dependency or a metadependency.
40
+
41
+ {% callout %}
42
+ **Note** — Bun currently only supports top-level `"overrides"`. [Nested overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) are not supported.
43
+ {% /callout %}
44
+
45
+ ```json-diff#package.json
46
+ {
47
+ "name": "my-app",
48
+ "dependencies": {
49
+ "foo": "^2.0.0"
50
+ },
51
+ + "overrides": {
52
+ + "bar": "~4.4.0"
53
+ + }
54
+ }
55
+ ```
56
+
57
+ ## `"resolutions"`
58
+
59
+ The syntax is similar for `"resolutions"`, which is Yarn's alternative to `"overrides"`. Bun supports this feature to make migration from Yarn easier.
60
+
61
+ As with `"overrides"`, _nested resolutions_ are not currently supported.
62
+
63
+ ```json-diff#package.json
64
+ {
65
+ "name": "my-app",
66
+ "dependencies": {
67
+ "foo": "^2.0.0"
68
+ },
69
+ + "resolutions": {
70
+ + "bar": "~4.4.0"
71
+ + }
72
+ }
73
+ ```
@@ -0,0 +1,57 @@
1
+ `bun patch` lets you persistently patch node_modules in a maintainable, git-friendly way.
2
+
3
+ Sometimes, you need to make a small change to a package in `node_modules/` to fix a bug or add a feature. `bun patch` makes it easy to do this without vendoring the entire package and reuse the patch across multiple installs, multiple projects, and multiple machines.
4
+
5
+ Features:
6
+
7
+ - Generates `.patch` files applied to dependencies in `node_modules` on install
8
+ - `.patch` files can be committed to your repository, reused across multiple installs, projects, and machines
9
+ - `"patchedDependencies"` in `package.json` keeps track of patched packages
10
+ - `bun patch` lets you patch packages in `node_modules/` while preserving the integrity of Bun's [Global Cache](https://bun.sh/docs/install/cache)
11
+ - Test your changes locally before committing them with `bun patch --commit <pkg>`
12
+ - To preserve disk space and keep `bun install` fast, patched packages are committed to the Global Cache and shared across projects where possible
13
+
14
+ #### Step 1. Prepare the package for patching
15
+
16
+ To get started, use `bun patch <pkg>` to prepare the package for patching:
17
+
18
+ ```bash
19
+ # you can supply the package name
20
+ $ bun patch react
21
+
22
+ # ...and a precise version in case multiple versions are installed
23
+ $ bun patch react@17.0.2
24
+
25
+ # or the path to the package
26
+ $ bun patch node_modules/react
27
+ ```
28
+
29
+ {% callout %}
30
+ **Note** — Don't forget to call `bun patch <pkg>`! This ensures the package folder in `node_modules/` contains a fresh copy of the package with no symlinks/hardlinks to Bun's cache.
31
+
32
+ If you forget to do this, you might end up editing the package globally in the cache!
33
+ {% /callout %}
34
+
35
+ #### Step 2. Test your changes locally
36
+
37
+ `bun patch <pkg>` makes it safe to edit the `<pkg>` in `node_modules/` directly, while preserving the integrity of Bun's [Global Cache](https://bun.sh/docs/install/cache). This works by re-creating an unlinked clone of the package in `node_modules/` and diffing it against the original package in the Global Cache.
38
+
39
+ #### Step 3. Commit your changes
40
+
41
+ Once you're happy with your changes, run `bun patch --commit <path or pkg>`.
42
+
43
+ Bun will generate a patch file in `patches/`, update your `package.json` and lockfile, and Bun will start using the patched package:
44
+
45
+ ```bash
46
+ # you can supply the path to the patched package
47
+ $ bun patch --commit node_modules/react
48
+
49
+ # ... or the package name and optionally the version
50
+ $ bun patch --commit react@17.0.2
51
+
52
+ # choose the directory to store the patch files
53
+ $ bun patch --commit react --patches-dir=mypatches
54
+
55
+ # `patch-commit` is available for compatibility with pnpm
56
+ $ bun patch-commit react
57
+ ```
@@ -0,0 +1,30 @@
1
+ The default registry is `registry.npmjs.org`. This can be globally configured in `bunfig.toml`:
2
+
3
+ ```toml
4
+ [install]
5
+ # set default registry as a string
6
+ registry = "https://registry.npmjs.org"
7
+ # set a token
8
+ registry = { url = "https://registry.npmjs.org", token = "123456" }
9
+ # set a username/password
10
+ registry = "https://username:password@registry.npmjs.org"
11
+ ```
12
+
13
+ To configure a private registry scoped to a particular organization:
14
+
15
+ ```toml
16
+ [install.scopes]
17
+ # registry as string
18
+ "@myorg1" = "https://username:password@registry.myorg.com/"
19
+
20
+ # registry with username/password
21
+ # you can reference environment variables
22
+ "@myorg2" = { username = "myusername", password = "$NPM_PASS", url = "https://registry.myorg.com/" }
23
+
24
+ # registry with token
25
+ "@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
26
+ ```
27
+
28
+ ### `.npmrc`
29
+
30
+ Bun also reads `.npmrc` files, [learn more](https://bun.sh/docs/install/npmrc).
@@ -0,0 +1,70 @@
1
+ Bun supports [`workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true#description) in `package.json`. Workspaces make it easy to develop complex software as a _monorepo_ consisting of several independent packages.
2
+
3
+ It's common for a monorepo to have the following structure:
4
+
5
+ ```
6
+ tree
7
+ <root>
8
+ ├── README.md
9
+ ├── bun.lockb
10
+ ├── package.json
11
+ ├── tsconfig.json
12
+ └── packages
13
+    ├── pkg-a
14
+    │   ├── index.ts
15
+    │   ├── package.json
16
+    │   └── tsconfig.json
17
+    ├── pkg-b
18
+    │   ├── index.ts
19
+    │   ├── package.json
20
+    │   └── tsconfig.json
21
+    └── pkg-c
22
+    ├── index.ts
23
+    ├── package.json
24
+    └── tsconfig.json
25
+ ```
26
+
27
+ In the root `package.json`, the `"workspaces"` key is used to indicate which subdirectories should be considered packages/workspaces within the monorepo. It's conventional to place all the workspace in a directory called `packages`.
28
+
29
+ ```json
30
+ {
31
+ "name": "my-project",
32
+ "version": "1.0.0",
33
+ "workspaces": ["packages/*"],
34
+ "devDependencies": {
35
+ "example-package-in-monorepo": "workspace:*"
36
+ }
37
+ }
38
+ ```
39
+
40
+ {% callout %}
41
+ **Glob support** — Bun supports full glob syntax in `"workspaces"` (see [here](https://bun.sh/docs/api/glob#supported-glob-patterns) for a comprehensive list of supported syntax), _except_ for exclusions (e.g. `!**/excluded/**`), which are not implemented yet.
42
+ {% /callout %}
43
+
44
+ Each workspace has it's own `package.json`. When referencing other packages in the monorepo, semver or workspace protocols (e.g. `workspace:*`) can be used as the version field in your `package.json`.
45
+
46
+ ```json
47
+ {
48
+ "name": "pkg-a",
49
+ "version": "1.0.0",
50
+ "dependencies": {
51
+ "pkg-b": "workspace:*"
52
+ }
53
+ }
54
+ ```
55
+
56
+ Workspaces have a couple major benefits.
57
+
58
+ - **Code can be split into logical parts.** If one package relies on another, you can simply add it as a dependency in `package.json`. If package `b` depends on `a`, `bun install` will install your local `packages/a` directory into `node_modules` instead of downloading it from the npm registry.
59
+ - **Dependencies can be de-duplicated.** If `a` and `b` share a common dependency, it will be _hoisted_ to the root `node_modules` directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.
60
+ - **Run scripts in multiple packages.** You can use the [`--filter` flag](https://bun.sh/docs/cli/filter) to easily run `package.json` scripts in multiple packages in your workspace.
61
+
62
+ {% callout %}
63
+ ⚡️ **Speed** — Installs are fast, even for big monorepos. Bun installs the [Remix](https://github.com/remix-run/remix) monorepo in about `500ms` on Linux.
64
+
65
+ - 28x faster than `npm install`
66
+ - 12x faster than `yarn install` (v1)
67
+ - 8x faster than `pnpm install`
68
+
69
+ {% image src="https://user-images.githubusercontent.com/709451/212829600-77df9544-7c9f-4d8d-a984-b2cd0fd2aa52.png" /%}
70
+ {% /callout %}
@@ -0,0 +1,289 @@
1
+ Bun ships as a single executable with no dependencies that can be installed a few different ways.
2
+
3
+ ## Installing
4
+
5
+ ### macOS and Linux
6
+
7
+ {% callout %}
8
+ **Linux users** — The `unzip` package is required to install Bun. Use `sudo apt install unzip` to install `unzip` package.
9
+ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Use `uname -r` to check Kernel version.
10
+ {% /callout %}
11
+
12
+ {% codetabs %}
13
+
14
+ ```bash#macOS/Linux_(curl)
15
+ $ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
16
+ # to install a specific version
17
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.0.0"
18
+ ```
19
+
20
+ ```bash#npm
21
+ $ npm install -g bun # the last `npm` command you'll ever need
22
+ ```
23
+
24
+ ```bash#Homebrew
25
+ $ brew install oven-sh/bun/bun # for macOS and Linux
26
+ ```
27
+
28
+ ```bash#Docker
29
+ $ docker pull oven/bun
30
+ $ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
31
+ ```
32
+
33
+ {% /codetabs %}
34
+
35
+ ### Windows
36
+
37
+ To install, paste this into a terminal:
38
+
39
+ {% codetabs %}
40
+
41
+ ```powershell#PowerShell/cmd.exe
42
+ > powershell -c "irm bun.sh/install.ps1|iex"
43
+ ```
44
+
45
+ ```powershell#npm
46
+ > npm install -g bun # the last `npm` command you'll ever need
47
+ ```
48
+
49
+ ```powershell#Scoop
50
+ > scoop install bun
51
+ ```
52
+
53
+ {% /codetabs %}
54
+
55
+ {% callout %}
56
+ Bun requires a minimum of Windows 10 version 1809
57
+ {% /callout %}
58
+
59
+ For support and discussion, please join the [#windows channel on our Discord](http://bun.sh/discord).
60
+
61
+ ## Docker
62
+
63
+ Bun provides a [Docker image](https://hub.docker.com/r/oven/bun/tags) that supports both Linux x64 and arm64.
64
+
65
+ ```bash
66
+ $ docker pull oven/bun
67
+ $ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
68
+ ```
69
+
70
+ There are also image variants for different operating systems.
71
+
72
+ ```bash
73
+ $ docker pull oven/bun:debian
74
+ $ docker pull oven/bun:slim
75
+ $ docker pull oven/bun:distroless
76
+ $ docker pull oven/bun:alpine
77
+ ```
78
+
79
+ ## Checking installation
80
+
81
+ To check that Bun was installed successfully, open a new terminal window and run `bun --version`.
82
+
83
+ ```sh
84
+ $ bun --version
85
+ 1.x.y
86
+ ```
87
+
88
+ To see the precise commit of [oven-sh/bun](https://github.com/oven-sh/bun) that you're using, run `bun --revision`.
89
+
90
+ ```sh
91
+ $ bun --revision
92
+ 1.x.y+b7982ac13189
93
+ ```
94
+
95
+ If you've installed Bun but are seeing a `command not found` error, you may have to manually add the installation directory (`~/.bun/bin`) to your `PATH`.
96
+
97
+ {% details summary="How to add to your `PATH`" %}
98
+ First, determine what shell you're using:
99
+
100
+ ```sh
101
+ $ echo $SHELL
102
+ /bin/zsh # or /bin/bash or /bin/fish
103
+ ```
104
+
105
+ Then add these lines below to bottom of your shell's configuration file.
106
+
107
+ {% codetabs %}
108
+
109
+ ```bash#~/.zshrc
110
+ # add to ~/.zshrc
111
+ export BUN_INSTALL="$HOME/.bun"
112
+ export PATH="$BUN_INSTALL/bin:$PATH"
113
+ ```
114
+
115
+ ```bash#~/.bashrc
116
+ # add to ~/.bashrc
117
+ export BUN_INSTALL="$HOME/.bun"
118
+ export PATH="$BUN_INSTALL/bin:$PATH"
119
+ ```
120
+
121
+ ```sh#~/.config/fish/config.fish
122
+ # add to ~/.config/fish/config.fish
123
+ export BUN_INSTALL="$HOME/.bun"
124
+ export PATH="$BUN_INSTALL/bin:$PATH"
125
+ ```
126
+
127
+ {% /codetabs %}
128
+ Save the file. You'll need to open a new shell/terminal window for the changes to take effect.
129
+
130
+ {% /details %}
131
+
132
+ ## Upgrading
133
+
134
+ Once installed, the binary can upgrade itself.
135
+
136
+ ```sh
137
+ $ bun upgrade
138
+ ```
139
+
140
+ {% callout %}
141
+ **Homebrew users** — To avoid conflicts with Homebrew, use `brew upgrade bun` instead.
142
+
143
+ **Scoop users** — To avoid conflicts with Scoop, use `scoop update bun` instead.
144
+
145
+ {% /callout %}
146
+
147
+ ## Canary builds
148
+
149
+ Bun automatically releases an (untested) canary build on every commit to `main`. To upgrade to the latest canary build:
150
+
151
+ ```sh
152
+ $ bun upgrade --canary
153
+ ```
154
+
155
+ The canary build is useful for testing new features and bug fixes before they're released in a stable build. To help the Bun team fix bugs faster, canary builds automatically upload crash reports to Bun's team.
156
+
157
+ [View canary build](https://github.com/oven-sh/bun/releases/tag/canary)
158
+
159
+ {% callout %}
160
+ **Note** — To switch back to a stable release from canary, run `bun upgrade --stable`.
161
+ {% /callout %}
162
+
163
+ ## Installing older versions of Bun
164
+
165
+ Since Bun is a single binary, you can install older versions of Bun by re-running the installer script with a specific version.
166
+
167
+ ### Installing a specific version of Bun on Linux/Mac
168
+
169
+ To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.1.6` or `bun-v1.1.1`.
170
+
171
+ ```sh
172
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.1.6"
173
+ ```
174
+
175
+ ### Installing a specific version of Bun on Windows
176
+
177
+ On Windows, you can install a specific version of Bun by passing the version number to the Powershell install script.
178
+
179
+ ```sh
180
+ # PowerShell:
181
+ $ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.1.6"
182
+ ```
183
+
184
+ ## Downloading Bun binaries directly
185
+
186
+ To download Bun binaries directly, you can visit the [releases page](https://github.com/oven-sh/bun/releases) page on GitHub.
187
+
188
+ For convenience, here are download links for the latest version:
189
+
190
+ - [`bun-linux-x64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip)
191
+ - [`bun-linux-x64-baseline.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64-baseline.zip)
192
+ - [`bun-windows-x64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-windows-x64.zip)
193
+ - [`bun-windows-x64-baseline.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-windows-x64-baseline.zip)
194
+ - [`bun-darwin-aarch64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-darwin-aarch64.zip)
195
+ - [`bun-linux-aarch64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-linux-aarch64.zip)
196
+ - [`bun-darwin-x64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-darwin-x64.zip)
197
+ - [`bun-darwin-x64-baseline.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-darwin-x64-baseline.zip)
198
+
199
+ The `baseline` binaries are built for older CPUs which may not support AVX2 instructions. If you run into an "Illegal Instruction" error when running Bun, try using the `baseline` binaries instead. Bun's install scripts automatically choose the correct binary for your system which helps avoid this issue. Baseline builds are slower than regular builds, so use them only if necessary.
200
+
201
+ <!--
202
+ ## Native
203
+
204
+ Works on macOS x64 & Silicon, Linux x64, Windows Subsystem for Linux.
205
+
206
+ ```sh
207
+ $ curl -fsSL https://bun.sh/install | bash
208
+ ```
209
+
210
+ Once installed, the binary can upgrade itself.
211
+
212
+ ```sh
213
+ $ bun upgrade
214
+ ```
215
+
216
+ Bun automatically releases an (untested) canary build on every commit to `main`. To upgrade to the latest canary build:
217
+
218
+ ```sh
219
+ $ bun upgrade --canary
220
+ ```
221
+
222
+ ## Homebrew
223
+
224
+ Works on macOS and Linux
225
+
226
+ ```sh
227
+ $ brew tap oven-sh/bun
228
+ $ brew install bun
229
+ ```
230
+
231
+ Homebrew recommends using `brew upgrade <package>` to install newer versions.
232
+
233
+ ## Docker
234
+
235
+ Works on Linux x64
236
+
237
+ ```sh
238
+ # this is a comment
239
+ $ docker pull oven/bun:edge
240
+ this is some output
241
+ $ docker run --rm --init --ulimit memlock=-1:-1 oven/bun:edge
242
+ $ docker run --rm --init --ulimit memlock=-1:-1 oven/bun:edge
243
+ this is some output
244
+ ``` -->
245
+
246
+ <!-- ## Completions
247
+
248
+ Shell auto-completion should be configured automatically when Bun is installed!
249
+
250
+ If not, run the following command. It uses `$SHELL` to determine which shell you're using and writes a completion file to the appropriate place on disk. It's automatically re-run on every `bun upgrade`.
251
+
252
+ ```bash
253
+ $ bun completions
254
+ ```
255
+
256
+ To write the completions to a custom location:
257
+
258
+ ```bash
259
+ $ bun completions > path-to-file # write to file
260
+ $ bun completions /path/to/directory # write into directory
261
+ ``` -->
262
+
263
+ ## Uninstall
264
+
265
+ If you need to remove Bun from your system, use the following commands.
266
+
267
+ {% codetabs %}
268
+
269
+ ```bash#macOS/Linux_(curl)
270
+ $ rm -rf ~/.bun # for macOS, Linux, and WSL
271
+ ```
272
+
273
+ ```powershell#Windows
274
+ > powershell -c ~\.bun\uninstall.ps1
275
+ ```
276
+
277
+ ```powershell#Scoop
278
+ > scoop uninstall bun
279
+ ```
280
+
281
+ ```bash#npm
282
+ $ npm uninstall -g bun
283
+ ```
284
+
285
+ ```bash#Homebrew
286
+ $ brew uninstall bun
287
+ ```
288
+
289
+ {% /codetabs %}