MemberJunction / MemberJunction/MJ
mj install v6.1.0-edge.6 cannot complete on a fresh distribution host: CodeGen emits no EntitySubclasses output when every entity is in an excluded schema
- Dominant language
- TSQL
- Stars
- 29
- Forks
- 6
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 308
Description
Found while rehearsing an Open App host install on 2026-09-12. **No Open App is involved** — this is a bare `mj install` on a clean machine and database.
## What happens
```bash
mj install -t v6.1.0-edge.6 --dir ./mj-host-test --config install.config.json --yes
```
fails its **codegen** phase:
```
✗ codegen failed (27s)
✗ [codegen] Package rebuild failed (exit code 2):
mj_generatedentities#build: ERROR command (…/packages/GeneratedEntities) npm run build exited (2)
→ Run "npm run build" manually at the repo root to see full error output, then re-run "mj codegen".
Installation failed.
Failed phase(s): codegen
```
Following the remediation the installer prints — re-running `mj codegen` — fails identically. There is no forward path from a stock install.
## Chain, fully traced
1. A brand-new host has entities in exactly one schema:
`SELECT SchemaName, COUNT(*) FROM __mj.Entity GROUP BY SchemaName` → `__mj | 383`, nothing else.
2. `__mj` is in CodeGen's **default** `excludeSchemas` (`['sys','staging','__mj']`), which the stock scaffold deliberately relies on — its own comment says *"Core entities (__mj schema) should not be modified by distributions."*
3. CodeGen therefore has zero entities to generate: `Generating SQL for 0 entities`.
4. `ActionSubclasses` still writes its output file as a header-only stub. **`EntitySubclasses` writes nothing at all** — `packages/GeneratedEntities/src/generated/` does not exist.
5. `packages/GeneratedEntities/src/index.ts` is one unconditional line:
`export * from './generated/entity_subclasses.js';`
6. `tsc` → `error TS2307: Cannot find module './generated/entity_subclasses.js'` → `npm run build` exits 2 → codegen phase fails → **install fails**.
The same missing file also kills MJAPI at boot:
```
Error: Cannot find module '…/packages/GeneratedEntities/dist/generated/entity_subclasses.js'
imported from …/packages/GeneratedEntities/dist/index.js
```
## It is not one file
The identical defect — CodeGen writes no output for an empty entity set, while a scaffold file imports that output unconditionally — breaks the Explorer too:
```
✘ [ERROR] Could not resolve "./generated/generated-forms.module"
✘ [ERROR] TS2307: Cannot find module './generated/generated-forms.module'
✘ [ERROR] NG1010: Value at position 7 in the NgModule.imports of AppModule is not a reference
```
`apps/MJExplorer/src/app/app.module.ts:47` imports `GeneratedFormsModule` from that path unconditionally.
## The asymmetry is the fix
`ActionSubclasses` emits a header-only stub for an empty set; `EntitySubclasses` and the Angular forms module emit nothing. Either make those emit the same stub, or make the scaffold's `index.ts` / `app.module.ts` tolerate absence.
## Workaround
Hand-write the two missing files as stubs (`export {}` and an empty `@NgModule`) and build. That is what this rehearsal did to continue — but a host operator who has just run one documented command should not have to.
## Environment
MJ `v6.1.0-edge.6`, distribution (non-monorepo) install, macOS, Node 24.20.0, npm, SQL Server 2022 in Docker.
Contributor guide
Research direction
Start by running the reported mj codegen or npm run build failure, then inspect packages/GeneratedEntities/src/index.ts and the generated output behavior for an empty entity set. Check apps/MJExplorer/src/app/app.module.ts:47 as the second unconditional generated-file import. Done means a fresh install with all entities in excluded schemas completes codegen and both the GeneratedEntities and Explorer builds succeed without hand-written files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, node.js, typescript
- Domain
- build-system, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100