Skip to main content
To add an npm package as an optional dependency, use the --optional flag.
terminal

This will add the package to optionalDependencies in package.json.
package.json

See Docs > Package manager for complete documentation of Bun’s package manager.