Runtimes
TypeScript is supported by multiple runtimes: Node.js (via tsx), Deno (natively) and Bun (natively).
By default, the TypeScript SDK executes functions using the Node.js runtime, but you can configure an alternative runtime in the package.json
file.
For now, the TypeScript SDK only supports Node.js (stable) and Bun (experimental).
To change the TypeScript SDK runtime, set the field dagger.runtime
in the package.json
file.
Node
Set the field to node
to use the Node.js runtime. Node.js is also the default runtime used if this field is omitted.
"dagger": {
"runtime": "node"
}
Bun
Set the field to bun
to use the Bun runtime.
"dagger": {
"runtime": "bun"
}
Bun runtime support is still experimental. Unexpected results may occur in some cases.
Automatic Detection
When a runtime is not explicitly defined within the package.json
file, Dagger automatically identifies the appropriate runtime by examining the project's lock files inside the project's dagger
directory.
-
If Dagger finds any of the following lock files :
package-lock.json
,yarn.lock
, orpnpm-lock.yaml
, it automatically selectsnode
as the runtime. -
In the absence of the lock files mentioned above, if a
bun.lockb
file is present, Dagger will choosebun
as the runtime. -
If no or only unknown lock files are present,
node
is chosen.
This behavior however should be seen as a sensible fallback and not as an explicit configuration.