Verso.JavaScript
1.0.15
dotnet add package Verso.JavaScript --version 1.0.15
NuGet\Install-Package Verso.JavaScript -Version 1.0.15
<PackageReference Include="Verso.JavaScript" Version="1.0.15" />
<PackageVersion Include="Verso.JavaScript" Version="1.0.15" />
<PackageReference Include="Verso.JavaScript" />
paket add Verso.JavaScript --version 1.0.15
#r "nuget: Verso.JavaScript, 1.0.15"
#:package Verso.JavaScript@1.0.15
#addin nuget:?package=Verso.JavaScript&version=1.0.15
#tool nuget:?package=Verso.JavaScript&version=1.0.15
Verso.JavaScript
JavaScript and TypeScript language kernels for Verso notebooks.
Uses Node.js (subprocess) when available for full npm and module support, with Jint (pure .NET) as an in-process fallback for JavaScript in environments without Node. TypeScript requires Node.js and auto-installs the TypeScript compiler on first use.
Features
- JavaScript kernel: Full ES2024+,
require(), dynamicimport(), top-levelawait, npm packages via#!npm - TypeScript kernel: Automatic transpilation via the TypeScript compiler API, same Node.js execution environment as JavaScript
- Jint fallback (JavaScript only): Pure .NET ES2024 interpreter, no external dependencies required
- Cross-kernel variables: Share values between JavaScript/TypeScript and other language kernels (C#, Python, F#)
- Console capture:
console.log/console.erroroutput rendered as cell outputs - Variable persistence: Variables declared with
varor assigned toglobalThispersist across cells
Getting Started
Verso.JavaScript is included with Verso Blazor Server and the VS Code extension. JavaScript and TypeScript cells are available immediately with no setup required.
// JavaScript cell
var greeting = "Hello from JavaScript!";
console.log(greeting);
// TypeScript cell
interface User { name: string; age: number }
var user: User = { name: "Alice", age: 30 };
console.log(`Hello, ${user.name}!`);
npm Packages
Use #!npm to install packages from a cell. Packages are stored in ~/.verso/node/ and available via require() in subsequent cells.
#!npm lodash
const _ = require('lodash');
console.log(_.capitalize('hello world'));
Kernels
JavaScript (javascript)
- Node.js mode: Spawns a persistent Node.js subprocess. Variables persist in the V8 global context across cells. Supports
require(), dynamicimport(), and top-levelawait. - Jint mode: Falls back automatically when Node.js is not installed. Supports standard ES2024 features. Does not support
require/import,async/awaitat top level, or npm packages.
TypeScript (typescript)
- Requires Node.js (no Jint fallback)
- Transpiles cells using
ts.transpileModule()with ES2022 target and CommonJS module output - The
typescriptnpm module is auto-installed silently on first use - Shares the same Node.js subprocess and variable scope as JavaScript cells
- Type annotations are stripped at transpile time; any valid TypeScript compiles and runs
Magic Commands
#!npm <packages>- Install npm packages (Node.js mode only). Packages are available immediately in subsequent cells viarequire().
Variable Sharing
Variables defined in JavaScript or TypeScript cells are automatically published to the shared variable store after each execution. Other kernels can read them:
// C# cell
var value = Variables.Get<long>("myJsVariable");
Variables from other kernels are injected into the JavaScript global scope before each cell execution. Only JSON-serializable values cross the boundary (functions, Symbols, and other non-serializable types are excluded).
Limitations
- Static
importdeclarations are not supported in cells. Useconst { x } = await import('y')instead. letandconstdeclarations are scoped to the cell. Usevaror bare assignment for cross-cell persistence.- TypeScript type checking is limited to transpile-time diagnostics (no cross-cell type awareness).
- Jint mode does not support Node.js APIs, npm packages, or async/await at the top level.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Jint (>= 4.7.1)
- Verso.Abstractions (>= 1.0.15)
-
net8.0
- Jint (>= 4.7.1)
- Verso.Abstractions (>= 1.0.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.