DevelopersLocal Testing Guide

Local Package Testing Guide

This guide shows you how to install and test your local geoai package in the examples and other projects.

The Next.js example already has convenient scripts set up:

Quick Start

# From the root directory
cd examples/live-examples-nextjs
 
# Build the main package and install it locally
pnpm run build:geoai
 
# Start development server
pnpm dev
 
# Or do both in one command
pnpm run build_dev

What This Does

  1. Builds the main package (pnpm run build in root)
  2. Installs the local package in the example
  3. Starts the Next.js dev server

Method 2: Manual Local Installation

Step 1: Build Your Package

# From root directory
pnpm build

Step 2: Install in Example

cd examples/live-examples-nextjs
 
# Option A: File reference (automatically updates)
pnpm install file:../../build
 
# Option B: Link using pnpm workspaces
pnpm link ../../
 
# Option C: Pack and install (most realistic)
cd ../../
pnpm pack
cd examples/live-examples-nextjs
pnpm install ../../geobase-js-geoai-0.0.1.tgz

Method 3: Using pnpm Workspaces (Best for Development)

Update Root package.json

Add to the root package.json:

{
  "name": "geoai-workspace",
  "workspaces": [".", "examples/*"]
}

Update Example package.json

{
  "dependencies": {
    "geoai": "workspace:*"
  }
}
# From root directory
pnpm install
 
# This will automatically link the workspace packages
# From root directory
pnpm build
cd build
npm link
 
# In your example
cd examples/live-examples-nextjs
npm link geoai
 
# To unlink later
npm unlink geoai

Testing Your Installation

1. Check Installation

cd examples/live-examples-nextjs
 
# Check if package is installed
pnpm list geoai
 
# Check node_modules
ls -la node_modules/geoai/

2. Test Imports in Code

Create test-imports.ts in the example:

// Test core import
import { geoai } from "geoai";
console.log("Core API:", geoai.tasks());
 
export const testImports = () => {
  console.log("✅ Import working!");
  return { geoai };
};

3. Test in Next.js Component

Update a component to test the imports:

// In src/app/test-page/page.tsx
import { geoai } from "geoai";
 
export default function TestPage() {
  
  useEffect(() => {
    console.log("Available tasks:", geoai.tasks());
    console.log("Available models:", geoai.models().length);
  }, []);
 
  return <div>Local package test - Check console</div>;
}

Development Workflow

For Active Development

# Terminal 1: Watch mode for package building
cd /path/to/geoai
pnpm build --watch
 
# Terminal 2: Next.js dev server
cd examples/live-examples-nextjs
pnpm dev

For Testing Changes

# Make changes to src/
# Then rebuild and test
pnpm build
cd examples/live-examples-nextjs
pnpm install file:../../build
pnpm dev

Troubleshooting

”Module not found” errors

# Clear node_modules and reinstall
cd examples/live-examples-nextjs
rm -rf node_modules pnpm-lock.yaml
pnpm install file:../../build

TypeScript errors

# Check if types are installed
ls -la node_modules/geoai/
 
# Should see:
# - geoai.js
# - index.d.ts

Import path issues

Make sure you’re using the correct import paths:

// ✅ Correct
import { geoai } from "geoai";
 
// ❌ Wrong
import { geoai } from "geoai/dist";

Cache issues

# Clear Next.js cache
cd examples/live-examples-nextjs
rm -rf .next
pnpm dev

Testing Different Scenarios

Create a Node.js script:

// test-core.mjs
import { geoai } from "geoai";
 
console.log("Tasks:", geoai.tasks());
console.log("Models:", geoai.models().length);

Test TypeScript Declarations

// Check autocomplete and type checking work
import { geoai, ProviderParams } from "geoai";
 
const params: ProviderParams = {
  /* should autocomplete */
};

Quick Commands Reference

# Build and test in one go
pnpm build && cd examples/live-examples-nextjs && pnpm install file:../../build && pnpm dev
 
# Reset and reinstall
rm -rf examples/live-examples-nextjs/node_modules && cd examples/live-examples-nextjs && pnpm install
 
# Check what's installed
cd examples/live-examples-nextjs && pnpm list geoai
 
# Test imports from command line
cd examples/live-examples-nextjs && node -e "import('geoai').then(m => console.log(m.geoai.tasks()))"