Bun / Install Specific Version
Install Specific Version
Use 'bun add' to install a specific version of a package in your project.
bun add <package>@<version> bun add <package>@<version> #!/bin/bash
# Install Specific Version
bun add {{package}}@{{version}} import subprocess
# Install Specific Version
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"bun",
"add",
"<package>@<version>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: bun not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
You need to install a specific version of a package for your project.
Command Builder
Tune the command before you copy it
bun add <package>@<version> Terminal Output
Expected runtime feedback
$ bun add express@4.17.1
✔ Installed express@4.17.1 Power User Variants
Optimized versions
bun add react@17.0.2 Install React version 17.0.2.
bun add lodash@4.17.21 Install Lodash version 4.17.21.
Unix Pipeline
Shell combinations
bun add vue@2.6.14 Install Vue version 2.6.14.
bun add axios@0.21.1 Install Axios version 0.21.1.
Troubleshooting
Common pitfalls
Package version not found
Solution: Ensure the version number is correct and available.
Permission denied
Solution: Run the command with appropriate permissions or use sudo.
Command Breakdown
What each part is doing
-
bun - Base Command
- The executable that performs this operation. Here it runs Bun before the shell applies any redirect operators.
-
<package> - package
- The value supplied for package.
-
<version> - version
- The value supplied for version.
How To Run
Execution path
- Step 1
Run the command: bun add express@4.17.1
- Step 2
Check package.json to confirm express version is 4.17.1.
Alternative Approaches
Comparable commands in other tools
Alternative package management tools for the same job.
ng add <package1 package2 ...> Npm / Unstar Package Otp Authentication npm unstar <package_name> --otp <otp> Npm / Search Packages With Combination Of Terms npm s <term1 term2 ...> Npm / Display Package Version npm version Pip / Generate Hash Package File pip hash <path/to/package.whl>