Prerequisites
Before you begin, ensure you have the following installed:- Node.js (version 18 or higher recommended)
- npm (comes with Node.js)
Getting started
Install dependencies
Install all required dependencies using npm:This will install all dependencies listed in
package.json, including:- React 19 and React DOM
- Vite for build tooling
- react-markdown and remark-gfm for markdown rendering
- Mermaid for diagram support
- lucide-react for icons
Available scripts
MD Viewer includes several npm scripts for development and production:Script details
npm run dev: Starts the Vite development server with hot module replacementnpm run build: Creates an optimized production build in thedistfoldernpm run preview: Previews the production build locally before deploymentnpm run lint: Runs ESLint to check for code quality issues
Development workflow
- Make your changes in the
srcdirectory - The development server will automatically reload
- Run
npm run lintto check for linting errors - Test your changes thoroughly
- Build the project with
npm run buildto ensure it compiles successfully
The development server uses Vite, which provides extremely fast hot module replacement and build times.
Troubleshooting
If you encounter issues:- Port already in use: Vite will automatically try the next available port if 5173 is occupied
- Module not found errors: Try deleting
node_modulesand runningnpm installagain - Build fails: Ensure you’re using a compatible Node.js version (18 or higher)