Registry / http-networking / node-api-dotnet

node-api-dotnet

JSON →
library0.9.19jsnpmunverified

node-api-dotnet is a JavaScript (Node.js) library that provides high-performance, in-process interoperability with .NET applications. It enables seamless bi-directional communication, allowing JavaScript applications to load .NET assemblies and invoke .NET APIs, and conversely, enabling .NET applications to interact with JavaScript packages and APIs. The package is currently in 'Public Preview' (version 0.9.19), indicating active development with potential for minor breaking API changes in future releases. It differentiates itself by leveraging Node-API (N-API), ensuring broad compatibility across Node.js versions without recompilation and support for other Node-API compatible JavaScript runtimes. Key features include TypeScript type-definition generation for .NET APIs, robust async/await support for .NET Tasks and JavaScript Promises, and efficient handling of data streams, providing a more integrated and performant alternative to inter-process communication solutions for mixed-language applications.

http-networkingserialization
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The module exports an object containing .NET namespaces as properties. For ESM, use a namespace import (`* as`) to access the full structure. For CommonJS, use `const dotnet = require('node-api-dotnet');`

import * as dotnet from 'node-api-dotnet';

Specific .NET types like `System.Console` are exposed as nested properties of the main `node-api-dotnet` module export, not as direct named exports from the top-level module.

import * as dotnet from 'node-api-dotnet'; const Console = dotnet.System.Console;

While `node-api-dotnet` ships with TypeScript type definitions, use `import type` when only referencing types to ensure the import is optimized away during compilation and doesn't cause runtime errors if the symbol is not a live runtime export.

import type { System } from 'node-api-dotnet';

Demonstrates importing the .NET interop module, calling a static .NET method, accessing a static property, and instantiating/using a .NET class (StringBuilder) from JavaScript with TypeScript.

import * as dotnet from 'node-api-dotnet'; // Using ESM for modern Node.js & TypeScript // 1. Accessing a static .NET class and method const Console = dotnet.System.Console; Console.WriteLine('Hello from .NET via JavaScript!'); // 2. Accessing a static property (e.g., .NET CLR Version) // System.Environment.Version is a common way to get CLR version in .NET const clrVersion = dotnet.System.Environment.Version.ToString(); console.log(`\n.NET CLR Version: ${clrVersion}`); // 3. Creating and using an instance of a .NET class (e.g., System.Text.StringBuilder) const StringBuilder = dotnet.System.Text.StringBuilder; const sb = new StringBuilder('Initial string'); sb.Append(' appended from JS!'); sb.Append(`\nCurrent UTC Time: ${new Date().toISOString()}`); const finalString = sb.ToString(); console.log(`\nStringBuilder output:\n${finalString}`); // Note: Async operations are also supported, e.g., for File I/O with .NET Tasks. // This example focuses on synchronous interop for brevity.
Debug
Known footguns
breakingThe project is currently in 'Public Preview' status. This means there may be minor breaking API changes in future releases as the project matures and stabilizes.
gotchaPerformance overhead can occur with excessive synchronous calls or marshalling large amounts of data between JavaScript and .NET contexts. Optimize interop boundaries for efficiency.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
Resources