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

.npmrc support - Bun

.npmrc support - BunSkip to main contentBun home pageSearch...⌘KInstall BunSearch...NavigationAdvanced Configuration.npmrc supportRuntimePackage ManagerBundlerTest RunnerGuidesReferenceBlogFeedbackdiv:first-child]:!hidden peer-[.is-custom]:[&>div:first-child]:sm:!hidden peer-[.is-custom]:[&>div:first-child]:md:!hidden peer-[.is-custom]:[&>div:first-child]:lg:!hidden peer-[.is-custom]:[&>div:first-child]:xl:!hidden">Core Commandsbun installbun addbun removebun updatebunxPublishing & Analysisbun publishbun outdatedbun whybun auditbun infoWorkspace ManagementWorkspacesCatalogsbun linkbun pmAdvanced Configurationbun patchbun --filterGlobal cacheIsolated installsLockfileLifecycle scriptsScopes and registriesOverrides and resolutionsSecurity Scanner API.npmrc supportOn this pageSupported optionsSet the default registrySet the registry for a specific scopeConfigure options for a specific registrylink-workspace-packages: Control workspace package installationsave-exact: Save exact versionsignore-scripts: Skip lifecycle scriptsdry-run: Preview changes without installingcache: Configure cache directoryca and cafile: Configure CA certificatesomit and include: Control dependency typesinstall-strategy and node-linker: Installation strategypublic-hoist-pattern and hoist-pattern: Control hoistingAdvanced Configuration.npmrc supportCopy 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_2shjinpfd9rqaabsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed">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_5hjinpfd9rqaabsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed">Bun supports loading configuration options from .npmrc files, allowing you to reuse existing registry/scope configurations. We recommend migrating your .npmrc file to Bun’s bunfig.toml format, as it provides more flexible options and can let you configure Bun-specific options. ​Supported options ​Set the default registry The default registry is used to resolve packages, its default value is npm’s official registry (https://registry.npmjs.org/). To change it, you can set the registry option in .npmrc: .npmrcCopyregistry=http://localhost:4873/ The equivalent bunfig.toml option is install.registry: bunfig.tomlCopyinstall.registry = "http://localhost:4873/" ​Set the registry for a specific scope @:registry allows you to set the registry for a specific scope: .npmrcCopy@myorg:registry=http://localhost:4873/ The equivalent bunfig.toml option is to add a key in install.scopes: bunfig.tomlCopy[install.scopes] myorg = "http://localhost:4873/" ​Configure options for a specific registry http:///:= allows you to set options for a specific registry: .npmrcCopy# set an auth token for the registry # ${...} is a placeholder for environment variables http://http://localhost:4873/:_authToken=${NPM_TOKEN} # or you could set a username and password # note that the password is base64 encoded http://http://localhost:4873/:username=myusername http://http://localhost:4873/:_password=${NPM_PASSWORD} # or use _auth, which is your username and password # combined into a single string, which is then base 64 encoded http://http://localhost:4873/:_auth=${NPM_AUTH} The following options are supported: _authToken username _password (base64 encoded password) _auth (base64 encoded username:password, e.g. btoa(username + ":" + password)) email The equivalent bunfig.toml option is to add a key in install.scopes: bunfig.tomlCopy[install.scopes] myorg = { url = "http://localhost:4873/", username = "myusername", password = "$NPM_PASSWORD" } ​link-workspace-packages: Control workspace package installation Controls how workspace packages are installed when available locally: .npmrcCopylink-workspace-packages=true The equivalent bunfig.toml option is install.linkWorkspacePackages: bunfig.tomlCopy[install] linkWorkspacePackages = true ​save-exact: Save exact versions Always saves exact versions without the ^ prefix: .npmrcCopysave-exact=true The equivalent bunfig.toml option is install.exact: bunfig.tomlCopy[install] exact = true ​ignore-scripts: Skip lifecycle scripts Prevents running lifecycle scripts during installation: .npmrcCopyignore-scripts=true This is equivalent to using the --ignore-scripts flag with bun install. ​dry-run: Preview changes without installing Shows what would be installed without actually installing: .npmrcCopydry-run=true The equivalent bunfig.toml option is install.dryRun: bunfig.tomlCopy[install] dryRun = true ​cache: Configure cache directory Set the cache directory path, or disable caching: .npmrcCopy# set a custom cache directory cache=/path/to/cache # or disable caching cache=false The equivalent bunfig.toml option is install.cache: bunfig.tomlCopy[install.cache] # set a custom cache directory dir = "/path/to/cache" # or disable caching disable = true ​ca and cafile: Configure CA certificates Configure custom CA certificates for registry connections: .npmrcCopy# single CA certificate ca="-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----" # multiple CA certificates ca[]="-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----" ca[]="-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----" # or specify a path to a CA file cafile=/path/to/ca-bundle.crt ​omit and include: Control dependency types Control which dependency types are installed: .npmrcCopy# omit dev dependencies omit=dev # omit multiple types omit[]=dev omit[]=optional # include specific types (overrides omit) include=dev Valid values: dev, peer, optional ​install-strategy and node-linker: Installation strategy Control how packages are installed in node_modules. Bun supports two different configuration options for compatibility with different package managers. npm’s install-strategy: .npmrcCopy# flat node_modules structure (default) install-strategy=hoisted # symlinked structure install-strategy=linked pnpm/yarn’s node-linker: The node-linker option controls the installation mode. Bun supports values from both pnpm and yarn: ValueDescriptionAccepted byisolatedSymlinked structure with isolated dependenciespnpmhoistedFlat node_modules structurepnpmpnpmSymlinked structure (same as isolated)yarnnode-modulesFlat node_modules structure (same as hoisted)yarn .npmrcCopy# symlinked/isolated mode node-linker=isolated node-linker=pnpm # flat/hoisted mode node-linker=hoisted node-linker=node-modules ​public-hoist-pattern and hoist-pattern: Control hoisting Control which packages are hoisted to the root node_modules: .npmrcCopy# packages matching this pattern will be hoisted to the root public-hoist-pattern=*eslint* # multiple patterns public-hoist-pattern[]=*eslint* public-hoist-pattern[]=*prettier* # control general hoisting behavior hoist-pattern=*

Was this page helpful?

YesNoSuggest editsRaise issueSecurity Scanner APIPrevious⌘IxgithubdiscordyoutubePowered by

智能索引记录