Skip to content

Installation

Terminal window
npm install solve-engine

The package ships both ESM and CommonJS builds with TypeScript declarations for each, so it works whether your project uses import or require.

Node 22 or newer, or any browser from the last few years. The engine has no DOM dependency and no Node-specific dependency, so the same build runs in a browser tab, a web worker, a Node process, or a serverless function.

TypeScript is optional. If you use it, everything is typed and no separate @types package is needed.

import { ExpressionEngine } from "solve-engine";
const engine = new ExpressionEngine("en");
const [result] = engine.evaluateExpression("2 + 2 * 10");
console.log(result.toNumber()); // 22

If that prints 22, you are set up.

The main entry gives you the engine and the common types. There are also focused subpath entries, so a bundler only pulls in the part you actually use.

ImportContains
solve-engineExpressionEngine, the package registry, common types
solve-engine/vmValue, ValueType, and value construction helpers
solve-engine/formatformatValue and formatting settings
solve-engine/languageEditor support: completions, token categories, highlighting
solve-engine/packagesThe built-in packages and their configuration types
solve-engine/constantsLocale definitions and engine configuration defaults
solve-engine/errorsThe structured error type and its taxonomy

A further set of entries exposes the pipeline internals for advanced use, listed in subpath exports. Anything not documented there is internal and can change between releases without a major version.

Currency conversion, weather and stock lookups reach the network. Currency and weather work out of the box against free, keyless endpoints. Stocks and the knowledge package are opt-in and require you to supply the fetching function yourself, which means the engine never holds an API key. See async and live data.