This guide helps you resolve common issues when using the Catalyst React Plugin with Vite or Webpack.
- Build Tool Detection Issues
- Vite-Specific Issues
- Webpack-Specific Issues
- Environment Variable Issues
- Build Errors
- Development Server Issues
- Debug Mode
Symptoms:
Error: No supported build tool detected.
Supported build tools: Vite, Webpack (via react-scripts or direct installation)
Causes:
- Neither Vite nor Webpack is installed
- Missing configuration files
- Incorrect package.json structure
Solutions:
-
For Vite projects:
npm install vite @vitejs/plugin-react --save-dev
-
For Webpack projects:
npm install react-scripts --save-dev
-
Verify package.json:
{ "dependencies": { "react": "^18.0.0" }, "devDependencies": { "vite": "^5.0.0" // or "react-scripts": "^5.0.0" } }
Symptoms:
- Plugin detects Vite but you want to use Webpack
- Plugin detects Webpack but you want to use Vite
Cause: Both build tools are present in the project (Vite takes priority).
Solutions:
-
To force Webpack:
- Remove Vite from dependencies
- Delete
vite.config.js
-
To force Vite:
- Ensure Vite is installed
- Create
vite.config.js(even if minimal)
-
Check detection:
# The CLI will log which tool was detected catalyst serve # Look for: "Detected build tool: vite" or "Detected build tool: webpack"
Symptoms:
Error: Vite is not installed in node_modules
Solution:
npm install vite @vitejs/plugin-react --save-devSymptoms:
Error: Required file missing: index.html
Expected location: project root
Cause:
Vite requires index.html at the project root, not in public/.
Solution:
-
Move index.html:
# Windows move public\index.html index.html # Linux/Mac mv public/index.html index.html
-
Update index.html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>React App</title> </head> <body> <div id="root"></div> <script type="module" src="/src/main.tsx"></script> </body> </html>
Symptoms:
Error: Required file missing: entry point
Expected location: src/main.tsx, src/main.jsx, src/index.tsx, or src/index.jsx
Solution:
-
Rename your entry file:
# If you have src/index.tsx # Vite looks for main.tsx first, but index.tsx also works
-
Or create src/main.tsx:
import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import './index.css'; ReactDOM.createRoot(document.getElementById('root')!).render( <React.StrictMode> <App /> </React.StrictMode> );
Symptoms:
Error: React version must be >= 16.10.0 for Vite support
Current version: 16.8.0
Solution:
npm install react@latest react-dom@latestSymptoms:
Error: Failed to resolve import "./Component"
Cause: Vite requires explicit file extensions in imports.
Solution:
-
Add file extensions:
// Before import Component from './Component'; // After import Component from './Component.tsx';
-
Or configure Vite:
// vite.config.js export default defineConfig({ resolve: { extensions: ['.tsx', '.ts', '.jsx', '.js'] } });
Symptoms:
- Changes don't reflect in browser
- Page requires manual refresh
Solutions:
-
Check Vite dev server is running:
catalyst serve
-
Verify port is not blocked:
# Check if port 3000 is available netstat -ano | findstr :3000 # Windows lsof -i :3000 # Linux/Mac
-
Clear Vite cache:
rm -rf node_modules/.vite
Symptoms:
Error: Cannot find module 'react-scripts'
Solution:
npm install react-scripts --save-devSymptoms:
- Build takes several minutes
- Development server slow to start
Solutions:
-
Consider migrating to Vite:
- See Vite Migration Guide
- Vite is 10-50x faster
-
Optimize Webpack:
- Clear cache:
rm -rf node_modules/.cache - Update dependencies:
npm update
- Clear cache:
Symptoms:
process.env.REACT_APP_API_URLis undefined (Webpack)import.meta.env.VITE_API_URLis undefined (Vite)
Solutions:
-
Check variable prefix:
# Webpack projects - use REACT_APP_ prefix REACT_APP_API_URL=https://api.example.com # Vite projects - use VITE_ prefix VITE_API_URL=https://api.example.com
-
Verify .env file location:
- Must be in project root
- Not in
src/or other subdirectories
-
Restart dev server:
# Environment variables are loaded at startup # Stop and restart the server after changing .env
-
Check .env file format:
# Correct VITE_API_URL=https://api.example.com # Incorrect (no spaces around =) VITE_API_URL = https://api.example.com
Symptoms:
- Getting development values in production
- Variables from wrong .env file
Cause: Environment file hierarchy not understood.
Solution:
File Priority (highest to lowest):
.env.[mode].local(e.g.,.env.production.local).env.[mode](e.g.,.env.production).env.local.env
Example:
# .env (default)
VITE_API_URL=https://dev-api.example.com
# .env.production (overrides .env in production)
VITE_API_URL=https://api.example.com
# .env.local (overrides both, gitignored)
VITE_API_URL=https://localhost:8080Symptoms:
Error: Vite build failed with exit code 1
Solutions:
-
Check build logs:
- Look for specific error messages above this error
- Common issues: TypeScript errors, missing dependencies
-
Verify all dependencies installed:
npm install
-
Check for TypeScript errors:
npx tsc --noEmit
-
Clear build cache:
# Vite rm -rf node_modules/.vite rm -rf build # Webpack rm -rf node_modules/.cache rm -rf build
Symptoms:
- Build completes but files missing
- index.html not in build directory
Solutions:
-
Check build output directory:
// vite.config.js export default defineConfig({ build: { outDir: 'build' // Ensure this matches expected directory } });
-
Verify index.html location:
- Vite: Must be at project root
- Webpack: Must be in
public/directory
Symptoms:
Warning: The bundle size is significantly larger than recommended.
Solutions:
-
Enable code splitting:
// Use dynamic imports const Component = lazy(() => import('./Component'));
-
Analyze bundle:
# Vite npm install rollup-plugin-visualizer --save-dev # Add to vite.config.js import { visualizer } from 'rollup-plugin-visualizer'; export default defineConfig({ plugins: [react(), visualizer()] });
-
Remove unused dependencies:
npm uninstall <unused-package>
Symptoms:
Error: Port 3000 is already in use
Solutions:
-
Use different port:
# The CLI will automatically try another port # Or specify in vite.config.js export default defineConfig({ server: { port: 3001 } });
-
Kill process using port:
# Windows netstat -ano | findstr :3000 taskkill /PID <PID> /F # Linux/Mac lsof -ti:3000 | xargs kill -9
Symptoms:
- Server starts but immediately crashes
- No error message displayed
Solutions:
-
Check Node.js version:
node --version # Should be >= 12.0.0 -
Clear all caches:
rm -rf node_modules rm package-lock.json npm install
-
Check for conflicting processes:
# Ensure no other dev servers running ps aux | grep vite # Linux/Mac tasklist | findstr vite # Windows
Symptoms:
- Dev server starts successfully
- Browser doesn't open automatically
Cause: This is expected behavior - the plugin doesn't auto-open by default.
Solution:
Manually open the URL shown in the terminal:
Local: http://localhost:3000/
Or configure auto-open in vite.config.js:
export default defineConfig({
server: {
open: true
}
});To get more detailed information about what the plugin is doing:
-
Check CLI output:
catalyst serve # Look for: "Detected build tool: vite" -
Enable Node.js debugging:
NODE_DEBUG=* catalyst serve -
Check build tool logs:
# Vite shows detailed logs by default # Webpack logs are in the terminal
Create a test script to see detection details:
// test-detection.js
const BuildToolDetector = require('./lib/detector/build-tool-detector');
const detector = new BuildToolDetector(process.cwd());
try {
const details = detector.getDetails();
console.log('Detection Details:', JSON.stringify(details, null, 2));
} catch (error) {
console.error('Detection Error:', error.message);
}Run it:
node test-detection.js-
Verify package.json:
cat package.json | grep -E "(vite|react-scripts|webpack)"
-
Check config files:
ls -la | grep -E "(vite.config|webpack.config)"
-
Verify node_modules:
ls node_modules | grep -E "(vite|react-scripts)"
If you're still experiencing issues:
-
Check existing documentation:
-
Gather information:
- Node.js version:
node --version - npm version:
npm --version - Plugin version: Check
package.json - Build tool detected: Check CLI output
- Full error message and stack trace
- Node.js version:
-
Create minimal reproduction:
- Isolate the issue in a small project
- Include package.json and config files
-
Open an issue:
- Include all gathered information
- Describe expected vs actual behavior
- Provide reproduction steps
A: The plugin will detect and use Vite (priority). To use Webpack, remove Vite dependencies and config.
A: Follow the Vite Migration Guide.
A: Yes! The plugin maintains 100% backward compatibility with Webpack projects.
A: Yes, create vite.config.js (Vite) or webpack.config.js (Webpack) in your project root.
A: Vite uses native ES modules and doesn't bundle during development, resulting in instant server start and fast HMR.
A: Minimal changes needed:
- Update environment variable prefixes (
REACT_APP_→VITE_) - Move
index.htmlto project root - Update imports to use
import.meta.envinstead ofprocess.env
A: Open an issue on the repository with:
- Detailed description
- Steps to reproduce
- Environment information
- Error messages