Skip to Content
๐Ÿš€ Getting StartedInstallation

Last Updated: 3/18/2026


Get Snake Game running on your local machine in minutes. This guide covers installing dependencies, starting the development server, and building for production.

Prerequisites

Youโ€™ll need Node.js installed on your system. The project uses npm for package management, which comes bundled with Node.js.

To verify Node.js is installed, run:

node --version

If you donโ€™t have Node.js, download it from nodejs.orgย . The project works with Node.js 16 or higher.

Clone the Repository

First, get the source code:

git clone https://github.com/jeverest/snake-game.git cd snake-game

Install Dependencies

The project has minimal dependencies: TypeScript and Vite. Install them with npm:

npm install

This installs:

  • TypeScript ~5.9.3 โ€” Type-checking and compilation
  • Vite ^7.1.7 โ€” Development server and build tooling

The complete dependency footprint is under 100MB, and installation typically completes in 30โ€“60 seconds on a modern connection.

Start the Development Server

Launch the development server with hot module replacement:

npm run dev

Vite starts a local server, typically at http://localhost:5173. The terminal output shows the exact URL:

VITE v7.1.7 ready in 234 ms โžœ Local: http://localhost:5173/ โžœ Network: use --host to expose

Open the URL in your browser. The game menu appears immediately โ€” no build step required. Vite serves TypeScript files directly during development and reloads automatically when you edit source files.

Verify the Installation

You should see the Snake Game menu with:

  • A High Score display (initially 0)
  • A Bot Profile dropdown with three options (Survival, Hunter, Explorer)
  • New Game and Start Demo Bot buttons

Click New Game to verify the game works. Press an arrow key or WASD to start playing. If the snake appears on a green grid and responds to input, installation succeeded.

Build for Production

To create an optimized production build:

npm run build

This command:

  1. Runs TypeScript type-checking with tsc
  2. Bundles and minifies code with vite build
  3. Outputs static files to the dist/ directory

The build typically takes 2โ€“5 seconds. Output shows the bundle size:

dist/index.html 0.52 kB dist/assets/index-abc123.js 29.87 kB โ”‚ gzip: 10.24 kB

The entire game bundles to under 30KB of JavaScript โ€” no chunking needed for this single-page application.

Preview the Production Build

To test the production build locally:

npm run preview

Vite starts a local server serving the dist/ directory, typically at http://localhost:4173. This lets you verify the production build works correctly before deploying to a web host.

Project Structure

After installation, your directory contains:

snake-game/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ main.ts # Game engine and rendering โ”‚ โ”œโ”€โ”€ game-types.ts # Type definitions โ”‚ โ”œโ”€โ”€ bots/ # AI bot implementations โ”‚ โ””โ”€โ”€ style.css # Game styling โ”œโ”€โ”€ index.html # Entry point โ”œโ”€โ”€ package.json # Dependencies and scripts โ””โ”€โ”€ tsconfig.json # TypeScript configuration

The src/ directory holds all game logic. Edit src/main.ts to modify game mechanics, or explore src/bots/ to customize AI behavior.

Troubleshooting

Port 5173 already in use โ€” Vite picks the next available port automatically. Check the terminal output for the actual URL.

TypeScript errors during build โ€” Run npm install again to ensure TypeScript is installed correctly.

Game doesnโ€™t load in browser โ€” Check the browser console for errors. Vite requires a modern browser with ES modules support (Chrome 87+, Firefox 78+, Safari 14+).

Whatโ€™s Next

  • Quick Start: Play your first game and learn the controls
  • Controls: Complete keyboard reference for gameplay and view customization