Search code examples
javascriptnode.jsnpmbun

How to add save-exact in bunfig.toml?


Is there an equivalent to .npmrc config save-exact in bun?

I tried to add

save-exact = true

to bunfig.toml but it does not work.

I use bun version 1.0.0.


Solution

  • It seems now bunfig supports a static config option to use exact dependencies, additional to the cli option: bun add --exact ...

    install.exact

    Whether to set an exact version in package.json. Default false.

    By default Bun uses caret ranges; if the latest version of a package is 2.4.1, the version range in your package.json will be ^2.4.1. This indicates that any version from 2.4.1 up to (but not including) 3.0.0 is acceptable.

    sample bunfig.toml:

    [install]
    exact = true
    

    Here is the source from the bun official documentation site: https://bun.sh/docs/runtime/bunfig#install-exact

    I hope this is what you are looking for

    Update:

    I tried this myself, and apparently the config is supported but not working, at least on my end. I will fallback for now to add the parameter --exact while installing packages, and I will be reporting the status of the functionality with each bun version.

    bun version tested: 1.0.2