Flickr4Java icon indicating copy to clipboard operation
Flickr4Java copied to clipboard

How to run .ts file inside a turbo repo?

Open informatica1234 opened this issue 1 year ago • 0 comments

I have a turbo-repo project. My goal is to run "index.ts" file located in "./apps/backend/src/migrations/dbMigrations/index.ts". I've tried to run from "backend" folder with:

1, "ts-node --project tsconfig.json ./src/migrations/dbCollections/index.ts" but I receive: TypeError: Unknown file extension ".ts" for ...\apps\backend\src\migrations\dbCollections\index.ts

  1. "node --loader ts-node/esm ./src/migrations/dbCollections/index.ts" but I receive:
triggerUncaughtException(
Waiting for the debugger to disconnect...

Error: ERR_UNSUPPORTED_DIR_IMPORT: ...index.ts
I import methods/objects from other ".ts" files. So maybe that's why I receive this error.
  1. "npx tsx .\src\migrations\dbCollections\index.ts" but I receive:
import { checkWrapperFieldMetadata } from "@monorepo/code-generator";
         ^

SyntaxError: The requested module '@monorepo/code-generator' does not provide an export named 'checkWrapperFieldMetadata'

I use imports from packages that I've wrote myself for the app.

Btw, my tsconfig.json looks like this:

{
  "extends": "../../packages/tsconfig/base.json",
  "compilerOptions": {
    "moduleResolution": "Node",
    "target": "es2016",
    "module": "ESNext",
    "experimentalDecorators": true,
    "types": ["node", "express", "vite/client"],
  }
}

The base.json looks like this:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Default",
  "compilerOptions": {
    "declaration": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "incremental": false,
    "isolatedModules": true,
    "lib": ["es2022", "DOM", "DOM.Iterable"],
    "module": "NodeNext",
    "moduleDetection": "force",
    "moduleResolution": "NodeNext",
    "noUncheckedIndexedAccess": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "ES2022"
  }
}

I ran out of solutions. Can you help me please?

I want to be able to run any ".ts" from my turbo-repo regardless of what "imports" are inside the file.

informatica1234 avatar Oct 01 '24 13:10 informatica1234