Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

chore: run scripts through node --import tsx instead of the tsx CLI

Mohamed Bassemf88626dfce10
diff --git a/.agents/skills/dev-env/SKILL.md b/.agents/skills/dev-env/SKILL.md
index bc651732..d9df91e1 100644
--- a/.agents/skills/dev-env/SKILL.md
+++ b/.agents/skills/dev-env/SKILL.md
@@ -68,8 +68,8 @@ Browser gotchas:
## 5. Troubleshooting and running pieces by hand
-- **`listen EPERM ... tsx-*/*.pipe`**: the tsx CLI (`pnpm db:migrate`, `pnpm workers`, `pnpm seed:apply`) opens an IPC socket that the Claude Code sandbox blocks. Run the file through node's loader instead, e.g. `(cd packages/db && node --import tsx migrate.ts)`. The script already does this.
-- **`EMFILE: too many open files, watch`, then `.next/dev` "was deleted" and endless restarts**: native file watching is blocked in the sandbox. Keep `WATCHPACK_POLLING=true`.
+- **`listen EPERM ... tsx-*/*.pipe`**: the bare `tsx` CLI opens an IPC socket that the Claude Code sandbox blocks. Run the file through node's loader instead, e.g. `(cd packages/db && node --import tsx migrate.ts)`. The repo's package scripts (`pnpm db:migrate`, `pnpm seed:apply`, …) already do this.
+- **`EMFILE: too many open files, watch`**: native file watching is blocked in the sandbox. For `next dev` this shows up as `.next/dev` "was deleted" and endless restarts; keep `WATCHPACK_POLLING=true`. `pnpm workers` (`node --watch`) fails the same way; use `pnpm dev:worktree`, which runs the workers without watching.
- **A stray `packages/db/db.db`**: migrations ran with an empty `DATA_DIR`. Scripts must `import "dotenv/config"` before `@karakeep/shared/config`, which parses `process.env` at import time. Delete the stray file and re-run.
- **Jobs never run / queue errors**: `queue.db` needs `pnpm db:migrate:queue` (or `(cd apps/workers && node --import tsx scripts/migrateQueue.ts)`). The workers also migrate it on startup; the web app never does.
- **Reset the data**: stop the script, then run `(cd tools/seed-snapshot && node --import tsx src/apply.ts --force)`.
diff --git a/apps/cli/package.json b/apps/cli/package.json
index 86cb07e8..8e368b4d 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -33,7 +33,7 @@
},
"scripts": {
"build": "vite build && chmod +x dist/index.mjs",
- "run": "tsx src/index.ts",
+ "run": "node --import tsx src/index.ts",
"lint": "oxlint --ignore-path=../../.gitignore .",
"lint:fix": "oxlint --ignore-path=../../.gitignore . --fix",
"format": "oxfmt --ignore-path=../../.gitignore --ignore-path=./.gitignore --check .",
diff --git a/apps/mcp/package.json b/apps/mcp/package.json
index 83ae48b5..eeecc029 100644
--- a/apps/mcp/package.json
+++ b/apps/mcp/package.json
@@ -26,7 +26,7 @@
},
"scripts": {
"build": "vite build && shx chmod +x dist/index.js",
- "run": "tsx src/index.ts",
+ "run": "node --import tsx src/index.ts",
"lint": "oxlint --ignore-path=../../.gitignore .",
"lint:fix": "oxlint --ignore-path=../../.gitignore . --fix",
"format": "oxfmt --ignore-path=../../.gitignore --ignore-path=./.gitignore --check .",
diff --git a/apps/workers/package.json b/apps/workers/package.json
index c891a8af..1530e396 100644
--- a/apps/workers/package.json
+++ b/apps/workers/package.json
@@ -67,9 +67,9 @@
"vitest": "^4.1.11"
},
"scripts": {
- "start": "tsx watch index.ts",
+ "start": "node --watch --import tsx index.ts",
"start:prod": "node dist/index.js",
- "migrate:queue": "tsx scripts/migrateQueue.ts",
+ "migrate:queue": "node --import tsx scripts/migrateQueue.ts",
"build": "tsdown",
"build:watch": "tsdown --watch",
"lint": "oxlint --ignore-path=../../.gitignore .",
diff --git a/packages/benchmarks/package.json b/packages/benchmarks/package.json
index 8f135de2..c372c445 100644
--- a/packages/benchmarks/package.json
+++ b/packages/benchmarks/package.json
@@ -5,7 +5,7 @@
"private": true,
"type": "module",
"scripts": {
- "bench": "tsx src/index.ts",
+ "bench": "node --import tsx src/index.ts",
"lint": "oxlint --ignore-path=../../.gitignore --ignore-pattern='setup/docker-logs/**' .",
"lint:fix": "oxlint --ignore-path=../../.gitignore --ignore-pattern='setup/docker-logs/**' . --fix",
"format": "oxfmt --ignore-path=../../.gitignore --ignore-path=./.gitignore --check .",
diff --git a/packages/db/package.json b/packages/db/package.json
index 964716b4..67e6fa36 100644
--- a/packages/db/package.json
+++ b/packages/db/package.json
@@ -7,7 +7,7 @@
"main": "index.ts",
"scripts": {
"typecheck": "tsc --noEmit",
- "migrate": "tsx migrate.ts",
+ "migrate": "node --import tsx migrate.ts",
"generate": "drizzle-kit generate",
"studio": "drizzle-kit studio",
"format": "oxfmt --ignore-path=../../.gitignore --check .",
diff --git a/packages/open-api/package.json b/packages/open-api/package.json
index 50a93759..ce4460ea 100644
--- a/packages/open-api/package.json
+++ b/packages/open-api/package.json
@@ -15,8 +15,8 @@
},
"scripts": {
"typecheck": "tsc --noEmit",
- "check": "tsx index.ts check",
- "generate": "tsx index.ts",
+ "check": "node --import tsx index.ts check",
+ "generate": "node --import tsx index.ts",
"format": "oxfmt --ignore-path=../../.gitignore --check .",
"format:fix": "oxfmt --ignore-path=../../.gitignore .",
"lint": "oxlint --ignore-path=../../.gitignore .",
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
index 43bc5583..bdc401bd 100644
--- a/packages/sdk/package.json
+++ b/packages/sdk/package.json
@@ -27,7 +27,7 @@
},
"scripts": {
"build": "vite build",
- "run": "tsx src/index.ts",
+ "run": "node --import tsx src/index.ts",
"lint": "oxlint --ignore-path=../../.gitignore .",
"lint:fix": "oxlint --ignore-path=../../.gitignore . --fix",
"format": "oxfmt --ignore-path=../../.gitignore --ignore-path=./.gitignore --check .",
diff --git a/tools/compare-models/package.json b/tools/compare-models/package.json
index 56ff93e9..0003e45a 100644
--- a/tools/compare-models/package.json
+++ b/tools/compare-models/package.json
@@ -7,7 +7,7 @@
},
"scripts": {
"build": "tsc && chmod +x dist/index.js",
- "run": "tsx --env-file=./.env src/index.ts",
+ "run": "node --env-file=./.env --import tsx src/index.ts",
"typecheck": "tsc --noEmit"
},
"dependencies": {
diff --git a/tools/seed-snapshot/package.json b/tools/seed-snapshot/package.json
index 94145c71..b9375ab6 100644
--- a/tools/seed-snapshot/package.json
+++ b/tools/seed-snapshot/package.json
@@ -5,8 +5,8 @@
"private": true,
"type": "module",
"scripts": {
- "apply": "tsx src/apply.ts",
- "snapshot": "tsx src/index.ts",
+ "apply": "node --import tsx src/apply.ts",
+ "snapshot": "node --import tsx src/index.ts",
"lint": "oxlint --ignore-path=../../.gitignore .",
"lint:fix": "oxlint --ignore-path=../../.gitignore . --fix",
"format": "oxfmt --ignore-path=../../.gitignore --check .",