nodejs-clr is a .NET library that provides Node-style APIs (filesystem, path, crypto, networking, etc.) for Tsonic projects.
It is Node-inspired (familiar ergonomics), but it is not Node.js itself and it is not an exact replica of the Node standard library.
Install and enable the bindings package:
# new project
tsonic init
tsonic add npm @tsonic/nodejs
# existing project
tsonic add npm @tsonic/nodejsThen import Node-style modules from @tsonic/nodejs/index.js:
import { console, fs, path } from "@tsonic/nodejs/index.js";
export function main(): void {
console.log(path.join("a", "b", "c"));
console.log(fs.readFileSync("./README.md", "utf-8"));
}Some namespaces are emitted as separate ESM entry points (for example nodejs.Http) and are imported via a subpath:
import { http } from "@tsonic/nodejs/nodejs.Http.js";Documentation:
docs/README.md- https://tsonic.org/nodejs/
Build:
dotnet buildIf dotnet build fails with "Build FAILED" but no errors (some sandboxed environments block MSBuild node sockets), try:
dotnet build -- -maxcpucount:1Test:
dotnet testThe @tsonic/nodejs package is generated from the compiled assembly via tsbindgen.
MIT