Summary
In a consumer app that installs tina4-nodejs from npm, importing the ORM subpath fails at module resolution:
import { getCollection } from "tina4-nodejs/orm";
// or: initDatabase, realtime, BaseModel, seedOrm, ...
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@tina4/core' imported from
node_modules/tina4-nodejs/packages/orm/src/migration.ts
The published packages/orm/src/*.ts import the bare workspace specifier @tina4/core (and likely @tina4/frond/@tina4/swagger elsewhere), which only resolves inside the monorepo. From an installed package there is no node_modules/@tina4/core, so resolution throws.
Impact: the entire ORM / DocStore / realtime surface exported from tina4-nodejs/orm is unusable from an installed app — getCollection, initDatabase, bindDatabase, realtime(), BaseModel, seedOrm, migrations. The server also logs ORM not available (install @tina4/orm to enable) on boot. The core package (tina4-nodejs: server, router, websocket, Auth, static serving, /js/tina4js.min.js) works fine — only the /orm subpath is affected.
Version
tina4-nodejs@3.13.69, Node.js 22/24, run via tsx.
Reproduce
mkdir repro && cd repro && npm init -y && npm pkg set type=module
npm i tina4-nodejs tsx
printf 'import { getCollection } from "tina4-nodejs/orm";\nconsole.log(typeof getCollection);\n' > t.ts
npx tsx t.ts
# -> ERR_MODULE_NOT_FOUND: Cannot find package '@tina4/core' imported from
# node_modules/tina4-nodejs/packages/orm/src/migration.ts
Expected
import ... from "tina4-nodejs/orm" resolves and getCollection/initDatabase/BaseModel are usable from an installed app (the DocStore is documented for consumer apps, e.g. getCollection with a Mongo URI or the SQLite fallback).
Likely fix
The @tina4/* workspace imports inside the published packages/orm (and frond/swagger) resolve only in the monorepo. Options:
- Publish the
@tina4/* packages and declare them as real dependencies of tina4-nodejs, so @tina4/core resolves from an install; or
- Rewrite the internal cross-package imports to relative paths before publish (e.g.
../../core/src/...) so the published tarball is self-contained; or
- Add
imports/subpath mappings so the bare @tina4/* specifiers resolve within the published package.
Workaround
Consumer apps needing Mongo persistence can use the mongodb driver directly instead of getCollection.
Found while building a Tina4 Node app; the core WebSocket + static serving works great, this is only the /orm subpath.
Summary
In a consumer app that installs
tina4-nodejsfrom npm, importing the ORM subpath fails at module resolution:The published
packages/orm/src/*.tsimport the bare workspace specifier@tina4/core(and likely@tina4/frond/@tina4/swaggerelsewhere), which only resolves inside the monorepo. From an installed package there is nonode_modules/@tina4/core, so resolution throws.Impact: the entire ORM / DocStore / realtime surface exported from
tina4-nodejs/ormis unusable from an installed app —getCollection,initDatabase,bindDatabase,realtime(),BaseModel,seedOrm, migrations. The server also logsORM not available (install @tina4/orm to enable)on boot. The core package (tina4-nodejs: server, router,websocket,Auth, static serving,/js/tina4js.min.js) works fine — only the/ormsubpath is affected.Version
tina4-nodejs@3.13.69, Node.js 22/24, run viatsx.Reproduce
Expected
import ... from "tina4-nodejs/orm"resolves andgetCollection/initDatabase/BaseModelare usable from an installed app (the DocStore is documented for consumer apps, e.g.getCollectionwith a Mongo URI or the SQLite fallback).Likely fix
The
@tina4/*workspace imports inside the publishedpackages/orm(andfrond/swagger) resolve only in the monorepo. Options:@tina4/*packages and declare them as realdependenciesoftina4-nodejs, so@tina4/coreresolves from an install; or../../core/src/...) so the published tarball is self-contained; orimports/subpath mappings so the bare@tina4/*specifiers resolve within the published package.Workaround
Consumer apps needing Mongo persistence can use the
mongodbdriver directly instead ofgetCollection.Found while building a Tina4 Node app; the core WebSocket + static serving works great, this is only the
/ormsubpath.