← 返回命令列表

Linux command

bun-run 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Run a JavaScript/TypeScript file

bun run [script.ts]

Run a package.json script

bun run [start]

Run file in watch mode

bun --watch run [script.ts]

List available scripts

bun run

Evaluate code string

bun run --eval "[console.log('hello')]"

Evaluate and print result

bun run --print "[1 + 2]"

Run with environment file

bun run --env-file [.env] [script.ts]

说明

bun run executes JavaScript, TypeScript, and JSX files using Bun's fast native transpiler. It can also run package.json scripts with lifecycle hook support. The command can be shortened to just bun followed by the file or script name, though built-in commands take precedence.

参数

--watch
Re-run on file changes. Must be placed before `run` in the command.
--hot
Enable hot reloading instead of full restart on file changes.
--eval, -e _code_
Evaluate argument as script
--print, -p _code_
Evaluate and print result
--env-file _file_
Load environment variables from file
--cwd _directory_
Set working directory
--silent
Suppress script output
--smol
Reduce memory usage at the cost of performance by running the garbage collector more frequently.
--if-present
Exit without error if the entrypoint or script does not exist.
--filter _pattern_
Run scripts in matching workspace packages by name pattern.
--bun
Force the script to run through Bun's runtime, overriding shebang lines.

FAQ

What is the bun-run command used for?

bun run executes JavaScript, TypeScript, and JSX files using Bun's fast native transpiler. It can also run package.json scripts with lifecycle hook support. The command can be shortened to just bun followed by the file or script name, though built-in commands take precedence.

How do I run a basic bun-run example?

Run `bun run [script.ts]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --watch do in bun-run?

Re-run on file changes. Must be placed before `run` in the command.