Vad är filformatet LOCKB?
En .lockb-fil är den binära låsfilen som skapas av Bun, pakethanteraren och körtidsmiljön för JavaScript och TypeScript från Oven. Den heter nästan alltid bun.lockb och ligger i roten av ett projekt. Bun skriver den när du kör bun install och registrerar hela det lösta beroendeträdet: varje paket, dess exakta version, dess metadata, dess underberoenden och integritetshashar. Genom att låsa allt detta kan varje teammedlem och CI-jobb installera exakt samma träd.
Oven byggde formatet som binärt för snabbhetens skull. Det lagrar data i linjära arrayer, refererar till paket via index eller genom en hash av paketnamnet, och deduplicerar långa strängar. Filen inleds med ASCII-headern bun-lockfile-format-v0. Nackdelen är att en binär låsfil är svår att granska och inte visas i Git-diffar, vilket är anledningen till att Bun v1.1.39 lade till en textbaserad låsfil och Bun v1.2 gjorde bun.lock till standard för nya projekt. Befintliga bun.lockb-filer fungerar fortfarande.
Säkerhet & trygghet
RISK: LOWA bun.lockb file is generated data, not an executable, so opening or committing it is safe. Bun can 'run' the file only in the sense that bun ./bun.lockb prints its contents; it does not execute arbitrary code from the file. The only real caution is supply-chain trust: the lockfile pins specific package versions and their sources, so review dependency changes as you would any lockfile update. Never edit it by hand, since a corrupted binary lockfile will fail to parse.
Formatdetaljer
i ett nötskalProgram som öppnar LOCKB-filer
bun bun.lockb in the project directory to print the lockfile as readable yarn.lock-style text, or bun install to use it. bun.lockb. bun.lockb and print its contents without installing Bun. bun bun.lockb to print the lockfile as readable text, or bun install to reinstall from it. bun.lockb as text inside the editor. bun.lockb contents in Node or the browser without Bun installed. bun bun.lockb for a readable text dump, or bun install to install dependencies from it. bun.lockb as readable text. git config diff.lockb.textconv bun so git diff shows bun.lockb changes as readable text. Tekniska detaljer
djup specifikation| Encoding | Binary (serialized struct-of-arrays memory dump) |
| Byte order | Little-endian (native to the machine that wrote it) |
| Container | Flat custom binary format, not a standard container |
| Compression | None; long strings over 88 characters are deduplicated to save space |
| Typical size | A few KB to a few hundred KB depending on dependency count |
| Structure | A header/magic string followed by linear arrays: package list, string buffer, dependency slices, resolutions, and hoisting trees. Packages are referenced by an auto-incrementing index or a hash of the package name rather than by repeated name strings. |
| Integrity | Stores npm-style integrity hashes for each resolved package; the format itself is version-tagged via the header string |
| Platforms | Windows, macOS, Linux |
| Notes | Designed for fast reads and memory mapping. It is not human-readable and does not render in Git or GitHub diffs without a textconv helper. Superseded as the default by the text-based bun.lock (JSONC) in Bun v1.2, but still supported. |
| Human Readable | No |
| Släppt | 2022 |
| Senaste version | bun-lockfile-format-v0 |
| Specifikation | github.com |
LOCKB-konverteringar
Frågor & svar
frågat av användareInga frågor än - bli den första att fråga om LOCKB-filer.
Vanliga frågor
Hur öppnar jag en bun.lockb-fil?
bun bun.lockb. Bun skriver ut låsfilen som läsbar text i yarn.lock-stil. Du behöver ha Bun installerat för detta.Varför är bun.lockb binär istället för text?
Bör jag checka in bun.lockb i Git?
Hur konverterar jag bun.lockb till den nya bun.lock?
bun install --save-text-lockfile --frozen-lockfile --lockfile-only och ta sedan bort den gamla bun.lockb. Bun v1.2 använder den textbaserade bun.lock som standard för nya projekt.Kan jag redigera en bun.lockb-fil för hand?
package.json och kör bun install för att generera om låsfilen. Att redigera binärfilen direkt kommer att korrumpera den.