MarkText logoMarkTextDocs
Developer documentation

Build Instructions#

MarkText is built from the pnpm workspace at the repository root. Compiling the application and packaging installers are separate steps.

Prerequisites

  • Node.js >=22.12.0 and pnpm >=10. Use the pnpm version pinned by packageManager in the root package.json.
  • Python 3 and a C++ toolchain for native dependencies. Release CI selects Python 3.12.
  • Build on the target operating system: Linux, macOS or Windows. The release workflow builds x64 and arm64 on native runners.

Linux

On Debian-based distributions:

sh
sudo apt-get install libx11-dev libxkbfile-dev libsecret-1-dev libfontconfig-dev rpm

On Red Hat-based distributions:

sh
sudo dnf install libX11-devel libxkbfile-devel libsecret-devel fontconfig-devel

On Arch Linux:

sh
sudo pacman -S libx11 libxkbfile libsecret fontconfig

See Linux development for additional tooling and troubleshooting. Running the application also requires Electron's desktop libraries; the Debian and RPM packages declare their runtime dependencies in packages/desktop/electron-builder.yml.

Windows

Install Build Tools for Visual Studio 2022 with the C++ toolchain and a Windows SDK. The repository's .npmrc sets msvs_version=2022 and clang=0 for native dependency builds.

macOS

Install Xcode Command Line Tools. The CI build sets CXXFLAGS to -std=gnu++20 -stdlib=libc++ when rebuilding native modules.

Install and compile

sh
git clone https://github.com/marktext/marktext.git
cd marktext
pnpm install
pnpm run build:unpack
pnpm -C packages/desktop exec electron-vite preview --skipBuild

Installation runs scripts/postinstall.ts, including native dependency setup, patching, Muya type generation and locale minification. build:unpack minifies locales and compiles the main, preload and renderer bundles. Despite its name, it does not run electron-builder or create an unpacked distribution directory. The explicit preview --skipBuild command launches the existing bundles. The root start script runs electron-vite preview without --skipBuild, so it rebuilds before launching.

Compiled bundles are written to packages/desktop/out/. The shorter pnpm run build only runs electron-vite; run locale minification separately if using it for a production preview.

Package installers

Run the command for your host platform:

CommandOutput
pnpm run build:win:x64Windows x64 NSIS installer and zip
pnpm run build:win:arm64Windows arm64 NSIS installer and zip
pnpm run build:mac:x64Intel macOS DMG and zip
pnpm run build:mac:arm64Apple Silicon macOS DMG and zip
pnpm run build:linux:x64Linux x64 AppImage, snap, deb, rpm and tar.gz
pnpm run build:linux:arm64Linux arm64 AppImage, deb, rpm and tar.gz

Each packaging script minifies locales, rebuilds native modules, compiles the app and runs electron-builder with publishing disabled. Installers land in the repository-root dist/, configured by directories.output: ../../dist in packages/desktop/electron-builder.yml.

The shorter commands remain available: build:win selects x64; build:mac and build:linux use their electron-builder configuration without an explicit architecture argument. Use the architecture-specific scripts to match CI.

Development and checks

Run all commands below from the repository root:

CommandPurpose
pnpm run devLaunch Electron with renderer hot reload
pnpm run lintCheck desktop/shared tooling code style
pnpm run typecheckBuild Muya declarations and check desktop TypeScript/Vue
pnpm run test:unitRun desktop unit tests
pnpm run test:e2eRun desktop Playwright tests
pnpm run rebuild-nativeRebuild native modules after changing Electron

The renderer hot-reloads through Vite. Reload the window with Ctrl+R if necessary; this also reruns preload. Restart pnpm run dev after main-process changes.

Package-specific test paths are relative to that package:

sh
pnpm -C packages/desktop exec vitest run test/unit/specs/markdown-basic.spec.ts
pnpm -C packages/desktop exec playwright test test/e2e/launch.spec.ts

Muya has its own checks:

sh
pnpm --filter @muyajs/core lint
pnpm --filter @muyajs/core lint:types
pnpm --filter @muyajs/core test
pnpm --filter @muyajs/core test:spec

Native image checks

On a development or packaged build, check these interactions using the real system clipboard, file manager and screenshot tool:

  • Drag a local PNG/JPEG into a saved document with image insertion set to copy to a folder. Verify the image renders, the copy exists in the configured image folder, and the Markdown points to it. Also check dragging a browser image URL.
  • Copy an image bitmap in a browser and paste it into the editor. Verify the image renders and follows the configured copy/upload action.
  • On macOS, use the application's screenshot action and select a region. Verify the captured image is inserted and persisted.

Record the application commit, platform and result. Engine tests simulate clipboard/drop data and mock host callbacks, so these checks cover native integration beyond those assertions.

For the documentation site, see Website development.