Developer Documentation#
Workspace commands
Run the commands below from the repository root. Desktop scripts proxy to packages/desktop; Muya (packages/muya) and the Next.js website (packages/website) have their own package scripts. See Architecture for the directory layout and Website development for documentation changes.
1. Project Setup
1.1 Pre-Requisites
-
Python 3 for native dependency builds; release CI selects Python 3.12
-
Node.js (
>=22.12.0) — the PR build CI uses Node 22.21.1, the release CI uses Node 24.14.1 -
pnpm
>=10; use the version pinned in the rootpackage.json(packageManager).
1.2 Linux Specific Pre-requisites
- Linux environments require additional dependencies, please see Linux Specific Pre-reqs
1.3 Windows Specific Pre-requisites
Install Visual Studio 2022 C++ build tools and a Windows SDK. The root .npmrc sets msvs_version=2022 and clang=0 for native dependency builds.
1.4 Clone and Install
git clone https://github.com/marktext/marktext.git
cd marktext
pnpm install1.5 Create minified locale files
- Installation and platform packaging scripts minify locales automatically.
build:unpackalso includes this step;devand the plainbuildscript do not.
pnpm run minify-locales1.6 Run in Development
pnpm run dev1.6.1 Some Points to Note:
- Restart
pnpm run devafter changing the main process. A window reload (Ctrl+R) reruns preload; restart development if a preload change is not reflected. - The renderer hot-reloads through Vite. Reload the window if it retains stale state.
- Compile targets:
mainandpreloadstill compile toCommonJSrendererisESModulesonly (take note when using any legacyCommonJSlibraries)
1.7 Build for Production
# For windows
$ pnpm run build:win
# For macOS
$ pnpm run build:mac
# For Linux
$ pnpm run build:linux1.8 Compile and test
pnpm run build:unpack compiles without packaging. pnpm run start runs electron-vite preview, which rebuilds before launching. To launch existing bundles without rebuilding, use pnpm -C packages/desktop exec electron-vite preview --skipBuild. Platform packaging commands above write installers to the repository-root dist/.
Run pnpm run lint, pnpm run typecheck and pnpm run test:unit for desktop changes. See Build instructions for single-spec commands, E2E tests and Muya checks.
