diff --git a/package.json b/package.json index b0e066cd..0b6430d2 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "node-llama-cpp": "^3.14.5", "picomatch": "^4.0.0", "sqlite-vec": "^0.1.7-alpha.2", + "tsx": "^4.0.0", "yaml": "^2.8.2", "zod": "^4.2.1" }, @@ -54,7 +55,6 @@ }, "devDependencies": { "@types/better-sqlite3": "^7.6.0", - "tsx": "^4.0.0", "vitest": "^3.0.0" }, "peerDependencies": { diff --git a/qmd b/qmd index 1cac947f..3ba444df 100755 --- a/qmd +++ b/qmd @@ -43,4 +43,13 @@ while [[ -L "$SOURCE" ]]; do done SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" -exec "$NODE" --import tsx "$SCRIPT_DIR/src/qmd.ts" "$@" +# Resolve tsx from qmd's own node_modules to avoid ESM bare-specifier +# resolution issues (Node resolves from CWD, not from the script location) +TSX_LOADER="$SCRIPT_DIR/node_modules/tsx/dist/esm/index.mjs" +if [[ ! -f "$TSX_LOADER" ]]; then + echo "Error: tsx not found at $TSX_LOADER" >&2 + echo "Run: cd $SCRIPT_DIR && npm install" >&2 + exit 1 +fi + +exec "$NODE" --import "$TSX_LOADER" "$SCRIPT_DIR/src/qmd.ts" "$@"