Getting Started
Enable Node.js APIs in a Tsonic Project
New project
tsonic init
tsonic add npm @tsonic/nodejs
Existing project
tsonic add npm @tsonic/nodejs
That will:
- Install the
@tsonic/nodejsbindings package in your workspace (package.json) fortsctypechecking - Apply the package’s
.NETdependency manifest (tsonic.bindings.json) totsonic.workspace.json- Adds the required
dotnet.frameworkReferences/dotnet.packageReferences - Installs any additional
typespackages referenced by the manifest
- Adds the required
Then run tsonic restore (or just tsonic build, which will restore via dotnet) to materialize the .NET dependencies.
Minimal Example
import { console, fs, path } from "@tsonic/nodejs/index.js";
export function main(): void {
const fullPath = path.join("src", "App.ts");
console.log(fullPath);
if (fs.existsSync(fullPath)) {
console.log(fs.readFileSync(fullPath, "utf-8"));
}
}
Notes
- Tsonic is ESM-first. Import submodules with
.jswhen you use a subpath (example:@tsonic/nodejs/nodejs.Http.js). - This library is Node-inspired, but many APIs intentionally follow .NET behavior where it improves ergonomics.