Skip to content

Commit 3c7b517

Browse files
committed
docs(install): add troubleshooting guide
1 parent ef6546b commit 3c7b517

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

troubleshooting.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Troubleshooting Guide
2+
3+
## Quick Start
4+
5+
For standard setup, this guide is not necessary. Installation works out of the box:
6+
7+
```bash
8+
npm install
9+
npm run dev
10+
```
11+
12+
Check the following sections if any problems arise.
13+
14+
## `npm install` crashes with Visual Studio errors
15+
16+
When running `npm install` without configuration, you may encounter errors like:
17+
18+
```text
19+
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
20+
gyp ERR! find VS You need to install the latest version of Visual Studio
21+
```
22+
23+
**Why this happens:**
24+
25+
This project uses `brain.js` (v2.0.0-beta.23) for neural network functionality. Brain.js depends on `gpu.js`, which in turn depends on `gl` (OpenGL bindings) - a native Node.js module that requires C++ compilation during installation. Normally, this requires Python 3.x and Visual Studio Build Tools. However, neither is required for this project.
26+
27+
**Solution:**
28+
29+
The project is configured to skip native module compilation entirely. A `.npmrc` file in the project root contains:
30+
31+
```text
32+
ignore-scripts=true
33+
```
34+
35+
This directs npm to skip all installation scripts, including native compilation. Run:
36+
37+
```bash
38+
npm install
39+
```
40+
41+
No additional tools (Python, Visual Studio, Build Tools) are required.
42+
43+
**Why this works:**
44+
45+
The `gl` package is required only for server-side GPU acceleration during training. This project runs brain.js entirely in the browser (client-side React), so it is not needed. Neural network training occurs in the browser rather than on a server, making `gl` compilation unnecessary.
46+
47+
## Other Common Issues
48+
49+
### Still getting gyp errors after cloning?
50+
51+
Make sure the `.npmrc` file exists in your project root. If it's missing:
52+
53+
1. Create `.npmrc` in the project root
54+
2. Add this line: `ignore-scripts=true`
55+
3. Run `npm install` again
56+
57+
### "Module 'gl' not found" at runtime
58+
59+
This should not occur during normal usage. If this error appears, `brain.js` is attempting server-side GPU acceleration. Verify that:
60+
61+
- All neural network code exists in components marked with `"use client"`
62+
- brain.js is not imported in server components or API routes
63+
64+
### `package-lock.json` conflicts or corrupted `node_modules`
65+
66+
Start fresh:
67+
68+
```bash
69+
rm -rf node_modules package-lock.json
70+
npm install
71+
```
72+
73+
This clears out any partial installations and rebuilds from scratch.
74+
75+
## Build & Deploy
76+
77+
The setup works for any deployment scenario:
78+
79+
- **Local development**: `npm run dev` - no compilation needed
80+
- **Production build**: `npm run build` - creates a static build
81+
- **GitHub Pages / Vercel / Netlify**: Static export works out of the box
82+
83+
```bash
84+
npm install # Installs packages, skips native compilation
85+
npm run build # Creates optimized production build
86+
```
87+
88+
## Advanced: Server-Side Training
89+
90+
> [!Warning]
91+
> Server-side training is not necessary for this project.
92+
93+
For server-side neural network training with GPU acceleration, the following is required:
94+
95+
1. Install Python 3.6+
96+
2. Install Visual Studio Build Tools with "Desktop development with C++" workload
97+
3. Remove or modify `.npmrc` to allow scripts
98+
4. Run `npm install` to compile native modules
99+
100+
For this project, browser-based training is sufficient and server-side training is unnecessary.
101+
102+
## For Future Developers
103+
104+
### Key Implementation Details
105+
106+
> [!Note]
107+
> **Do not remove `.npmrc`**
108+
> This file is critical for installation to succeed without C++ build tools. All neural network code runs client-side in the browser, so native module compilation is skipped.
109+
110+
**`brain.js` runs client-side only**
111+
All neural network code resides in `"use client"` components. Training operates in the browser with small datasets. Server-side GPU acceleration is not required.
112+
113+
**Static deployment ready**
114+
The project exports as static HTML/JS/CSS and can deploy to any static host.
115+
116+
### Adding new dependencies
117+
118+
Most packages install normally:
119+
120+
```bash
121+
npm install <package>
122+
```
123+
124+
If a package requires install scripts:
125+
126+
```bash
127+
npm install <package> --ignore-scripts=false
128+
```
129+
130+
## Resources
131+
132+
- [brain.js documentation](https://github.com/BrainJS/brain.js)
133+
- [npm config: ignore-scripts](https://docs.npmjs.com/cli/v10/using-npm/config#ignore-scripts)
134+
- [node-gyp Windows setup](https://github.com/nodejs/node-gyp#on-windows)

0 commit comments

Comments
 (0)