id: version-0.10.0-node title: Node.js
Install with npm
:
npm install katex
# or globally
npm install -g katex
Install with Yarn
:
yarn add katex
# or globally
yarn global add katex
To build you will need Git, Node.js 6.9 or later, and Yarn.
Clone a copy of the GitHub source repository:
git clone https://github.com/KaTeX/KaTeX.git
cd KaTeX
Then install dependencies and run build
script:
yarn
yarn build
If you'd like to use the built KaTeX in other projects, install the package by specifying the path:
yarn add /path/to/KaTeX
# or using npm
npm install /path/to/KaTeX
You can manually download the package and source code from GitHub releases.
KaTeX is exported as a CommonJS module, which can be imported using require
:
const katex = require('katex');
If you're using a module loader, transpiler, or bundler that supports interoperability
between ECMAScript module and CommonJS module, you can use import
:
import katex from 'katex';
KaTeX also provides an ECMAScript module:
import katex from 'katex/dist/katex.mjs'
The ES module contains ES6 syntaxes and features, and may need transpiling to use in old environments: