Project Setup
What We’re Building
In this guide, you’ll set up a complete modding environment that lets you:
- Write mod code with helpful auto-completion (IntelliSense)
- Automatically build and package your mod
- Test changes quickly without manual file copying
Think of this as setting up a workshop with all the right tools before you start crafting.
Prerequisites & Installation
What You Need
Before we begin, you’ll need to install a few tools. Don’t worry - they’re all free and we’ll walk through each one.
Required Tools:
1. Node.js (JavaScript Runtime)
Node.js lets us run the build tools that compile and package your mod.
Windows Installation:
- Go to nodejs.org
- Click “Download the LTS version” (the green button)
- Run the downloaded installer (.msi file)
- Important: Check “Add to PATH” during installation (should be default)
- Restart any open command prompts after installation
Verify it worked:
# Open Command Prompt or PowerShell and run:
node --version
# Should show something like: v18.17.0
2. Code Editor (VS Code Recommended)
You can use any text editor, but VS Code provides the best experience with auto-completion and error highlighting.
Windows Installation:
- Go to code.visualstudio.com
- Download and run the installer
- During setup, check “Add to PATH” and “Register Code as editor for supported file types”
3. Git (Version Control)
Git helps you manage your code changes and download the mod template.
Windows Installation:
- Go to git-scm.com
- Download and run the installer
- Use default settings (they’re fine for our needs)
Verify it worked:
git --version
# Should show something like: git version 2.40.1
Getting the Mod Template
Now that your tools are installed, let’s get the starter template for your mod.
Step 1: Choose Your Approach
You have two options to start your project:
Option A: Fork on GitHub (Recommended) Best if you want to use GitHub for backup and collaboration
- Create a GitHub account (if you don’t have one) at github.com
- Visit the template: AFNM Example Mod repository
- Click “Fork” (top-right corner) to create your own copy
- Clone your fork locally:
# Replace YOUR-USERNAME with your actual GitHub username git clone https://github.com/YOUR-USERNAME/AfnmExampleMod.git my-mod-project
Option B: Direct Download (Simpler) Good for getting started quickly
- Download the template: Go to the AFNM Example Mod repository
- Click “Code” → “Download ZIP”
- Extract the ZIP to a folder like
C:\Users\YourName\Documents\my-mod-project
- Open Command Prompt/PowerShell in that folder and run:
git init
Step 2: Open Your Project
- Open VS Code
- File → Open Folder
- Navigate to and select your mod project folder
VS Code will open with your project files visible in the sidebar.
Step 3: Install Project Dependencies
Dependencies are pre-built code libraries that your mod uses (like TypeScript compiler, build tools, etc.).
In VS Code:
- Open the terminal: View → Terminal (or Ctrl+`)
- Run the install command:
npm install
What this downloads:
- TypeScript compiler and AFNM type definitions (for auto-completion)
- Build tools (Vite, Rollup) that package your mod
- Development utilities for testing and debugging
This may take 1-2 minutes. You’ll see a progress indicator as packages download.
Success indicators:
- No red error messages
- A new
node_modules/
folder appears in your project - VS Code shows TypeScript IntelliSense when you open
.ts
files
Common Issues:
- “npm: command not found” - Node.js wasn’t installed correctly. Reinstall and make sure “Add to PATH” is checked.
- Permission errors on Windows - Try running VS Code as Administrator, or use PowerShell instead of Command Prompt.
Personalizing Your Mod
Step 4: Update Mod Information
Your mod needs a name, description, and author information. This appears in-game and on Steam Workshop.
Open package.json
(in your project root) and find this section:
{
"name": "my-game-mod",
"version": "0.0.1",
"description": "A mod for AFNM",
"author": {
"name": "<your name>"
}
}
Update it to something like:
{
"name": "mystic-tea-cultivation",
"version": "1.0.0",
"description": "Adds tea-based cultivation techniques and mystical tea gardens to explore",
"author": {
"name": "TeaMaster92"
}
}
Field Guidelines:
- name: Lowercase, use hyphens instead of spaces (this becomes your mod’s technical ID)
- version: Start with “1.0.0” for your first release
- description: 1-2 sentences explaining what your mod adds
- author.name: Your modding alias (avoid using your real name for privacy)
Step 5: Test Your Setup
Let’s verify everything is working correctly by building your mod:
In VS Code terminal, run:
# Build your mod package
npm run build
Expected output:
> afnm-example-mod@1.0.0 build
> vite build
✓ built in 1.23s
This command:
- Compiles your TypeScript code
- Bundles your assets
- Creates a packaged mod ready for the game
- Outputs a ZIP file in the
builds/
folder
If you see errors: Double-check that you installed Node.js correctly and ran npm install
without errors.
Success indicators:
- No red error messages
- A new
builds/
folder appears - Inside
builds/
you should see a ZIP file likemy-mod-1.0.0.zip
Understanding Your Project
Project Structure Explained
Here’s what each folder and file does in your mod project:
your-mod-project/
├── src/
│ ├── modContent/
│ │ └── index.ts # ← Your mod code goes here
│ └── assets/ # ← Images, sounds, etc.
├── builds/ # ← Generated mod packages (appears after build)
├── docs/ # ← This documentation site
├── package.json # ← Mod information and settings
├── tsconfig.json # ← TypeScript compiler settings
└── node_modules/ # ← Downloaded dependencies (don't edit)
Key files you’ll work with:
src/modContent/index.ts
- This is where you write your mod logicsrc/assets/
- Put your images, sounds, and other files herepackage.json
- Contains your mod’s name, version, and descriptionbuilds/
- Contains packaged mod files ready for the game
Files you can ignore:
node_modules/
- Auto-generated, never edit these filestsconfig.json
- Compiler settings, rarely needs changesdocs/
- The documentation website you’re reading now
Development Workflow
Essential Commands
Here are the commands you’ll use regularly while developing your mod:
# Install dependencies (run once after downloading template)
npm install
# Build mod package for testing in-game
npm run build
Important: Unlike web development, you can’t run mods directly with npm run dev
. You must build your mod and install it in the game to test it.
Typical workflow:
- Edit your mod files in VS Code
- Run
npm run build
to package your mod - Copy the ZIP file from
builds/
to your game’smods/
folder - Restart the game to test your changes
- Repeat the cycle for iteration
VS Code Setup Tips
Recommended Extensions (VS Code should auto-suggest these):
- TypeScript and JavaScript Language Features (built-in, should be enabled)
- Prettier - Code formatter (keeps your code neat)
Useful VS Code features:
- Auto-completion: Type
window.modAPI.
and VS Code shows available functions - Error highlighting: Red squiggly lines show syntax errors
- Integrated terminal: View → Terminal to run commands without leaving VS Code
Version Control (Optional but Recommended)
Git helps you track changes and backup your work. Basic workflow:
# Save your current work
git add .
git commit -m "Added my first tea item"
# Create a branch for new features
git checkout -b feature/tea-garden-location
# Push to GitHub (if you forked the repo)
git push origin main
Or use GitHub Desktop for a visual interface: desktop.github.com
Troubleshooting
Common Setup Issues
“npm: command not found”
- Node.js wasn’t installed correctly
- Solution: Reinstall Node.js, ensure “Add to PATH” is checked, restart VS Code
“No TypeScript IntelliSense”
- VS Code isn’t recognizing TypeScript files
- Solution: Open a
.ts
file, then press Ctrl+Shift+P, type “TypeScript: Restart TS Server”
Build errors about missing files
- Dependencies weren’t installed properly
- Solution: Delete
node_modules/
folder, runnpm install
again
Permission errors on Windows
- Windows blocking npm from writing files
- Solution: Run VS Code as Administrator, or use PowerShell instead of Command Prompt
Next Steps
🎉 Congratulations! Your development environment is now set up and ready for modding.
You now have:
- ✅ A working mod project with auto-completion
- ✅ Build tools that package your mod automatically
- ✅ A development workflow for quick iteration
Ready to create content? Continue to: Mod Development Guide