温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/docs/pm/cli/patch
点击访问原文链接

bun patch - Bun

bun patch - BunDocumentation Index

Fetch the complete documentation index at: /docs/llms.txt

Use this file to discover all available pages before exploring further.

Skip to main contentBun home pageSearch...⌘KInstall BunSearch...NavigationAdvanced Configurationbun patchRuntimePackage ManagerBundlerTest RunnerGuidesReferenceBlogFeedback:first-child]:!hidden peer-[.is-custom]:[&>:first-child]:sm:!hidden peer-[.is-custom]:[&>:first-child]:md:!hidden peer-[.is-custom]:[&>:first-child]:lg:!hidden peer-[.is-custom]:[&>:first-child]:xl:!hidden">Core Commandsbun installbun addbun removebun updatebunxPublishing & Analysisbun publishbun outdatedbun whybun auditbun infoWorkspace ManagementWorkspacesCatalogsbun linkbun pmAdvanced Configurationbun patchbun --filterGlobal cacheGlobal virtual storeIsolated installsLockfileLifecycle scriptsScopes and registriesOverrides and resolutionsSecurity Scanner API.npmrc supportOn this pageStep 1. Prepare the package for patchingStep 2. Test your changes locallyStep 3. Commit your changesCLI UsagePatch GenerationDependency ManagementProject Files & LockfilesInstallation ControlNetwork & RegistryPerformance & ResourceCachingOutput & LoggingPlatform TargetingGlobal Configuration & ContextHelpAdvanced Configurationbun patchCopy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_n4ctdbsnlht5lebsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed">*]:[overflow-wrap:anywhere]">

Persistently patch node_modules packages in a git-friendly way

Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_1cctdbsnlht5lebsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed">bun patch lets you persistently patch node_modules in a maintainable, git-friendly way. Sometimes, you need to make a small change to a package in node_modules/ to fix a bug or add a feature. bun patch lets you do this without vendoring the entire package and reuse the patch across multiple installs, multiple projects, and multiple machines. Features: Generates .patch files applied to dependencies in node_modules on install .patch files can be committed to your repository, reused across multiple installs, projects, and machines "patchedDependencies" in package.json keeps track of patched packages bun patch lets you patch packages in node_modules/ while preserving the integrity of Bun’s Global Cache Test your changes locally before committing them with bun patch --commit To preserve disk space and keep bun install fast, patched packages are committed to the Global Cache and shared across projects where possible ​Step 1. Prepare the package for patching To get started, use bun patch to prepare the package for patching: terminal
# you can supply the package name
bun patch react

# ...and a precise version in case multiple versions are installed
bun patch react@17.0.2

# or the path to the package
bun patch node_modules/react
Don’t forget to call bun patch ! This ensures the package folder in node_modules/ contains a fresh copy of the package with no symlinks/hardlinks to Bun’s cache.If you forget to do this, you might end up editing the package globally in the cache! ​Step 2. Test your changes locally bun patch makes it safe to edit the in node_modules/ directly, while preserving the integrity of Bun’s Global 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. ​Step 3. Commit your changes Once you’re happy with your changes, run bun patch --commit . Bun will generate a patch file in patches/, update your package.json and lockfile, and Bun will start using the patched package: terminal
# you can supply the path to the patched package
bun patch --commit node_modules/react

# ... or the package name and optionally the version
bun patch --commit react@17.0.2

# choose the directory to store the patch files
bun patch --commit react --patches-dir=mypatches

# `patch-commit` is available for compatibility with pnpm
bun patch-commit react
​CLI Usage
bun patch package>@version>
​Patch Generation ​--commitbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Install a package containing modifications in dir ​--patches-dirstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">The directory to put the patch file in (only if —commit is used) ​Dependency Management ​--productionbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Don’t install devDependencies. Alias: -p ​--ignore-scriptsbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Skip lifecycle scripts in the project’s package.json (dependency scripts are never run) ​--trustbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Add to trustedDependencies in the project’s package.json and install the package(s) ​--globalbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Install globally. Alias: -g ​--omitstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Exclude dev, optional, or peer dependencies from install ​Project Files & Lockfiles ​--yarnbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Write a yarn.lock file (yarn v1). Alias: -y ​--no-savebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Don’t update package.json or save a lockfile ​--savebooleandefault:"true"p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Save to package.json (true by default) ​--frozen-lockfilebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Disallow changes to lockfile ​--save-text-lockfilebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Save a text-based lockfile ​--lockfile-onlybooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Generate a lockfile without installing dependencies ​Installation Control ​--backendstringdefault:"clonefile"p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Platform-specific optimizations for installing dependencies. Possible values: clonefile (default), hardlink, symlink, copyfile ​--linkerstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Linker strategy (one of isolated or hoisted) ​--dry-runbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Don’t install anything ​--forcebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Always request the latest versions from the registry & reinstall all dependencies. Alias: -f ​--no-verifybooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Skip verifying integrity of newly downloaded packages ​Network & Registry ​--castringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Provide a Certificate Authority signing certificate ​--cafilestringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Same as —ca, but as a file path to the certificate ​--registrystringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Use a specific registry by default, overriding .npmrc, bunfig.toml, and environment variables ​--network-concurrencynumberdefault:"48"p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Maximum number of concurrent network requests (default 48) ​Performance & Resource ​--concurrent-scriptsnumberdefault:"5"p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Maximum number of concurrent jobs for lifecycle scripts (default 5) ​Caching ​--cache-dirstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Store & load cached data from a specific directory path ​--no-cachebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Ignore manifest cache entirely ​Output & Logging ​--silentbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Don’t log anything ​--quietbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Only show tarball name when packing ​--verbosebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Excessively verbose logging ​--no-progressbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Disable the progress bar ​--no-summarybooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Don’t print a summary ​Platform Targeting ​--cpustringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Override CPU architecture for optional dependencies (e.g., x64, arm64, * for all) ​--osstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Override operating system for optional dependencies (e.g., linux, darwin, * for all) ​Global Configuration & Context ​--configstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Specify path to config file (bunfig.toml). Alias: -c ​--cwdstringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Set a specific current working directory ​Help ​--helpbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Print this help menu. Alias: -h

Was this page helpful?

YesNoSuggest editsRaise issuebun pmPreviousbun --filterNext⌘IxgithubdiscordyoutubePowered byThis documentation is built and hosted on Mintlify, a developer documentation platform

bun patch - Bun,AI智能索引,全网链接索引,智能导航,网页索引

    Persistently patch node_modules packages in a git-friendly way