-- Runing a TS files code from a Next app created with `npm` command --

Hello devs, i m bulding features for an app. that integrates users repo into the code in order to obtain info for that project , currently I run out of solutions to run this file where I wrote the github logic Here s the output in the terminal :
No description
9 Replies
Beyond^sight
Beyond^sightOP5mo ago
that s the actual tsconfig.json : { "compilerOptions": { "target": "ESNext", "module": "ESNext", "moduleResolution": "Node", "esModuleInterop": true, "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "strict": true, "skipLibCheck": true, "noEmit": true, "baseUrl": ".", "paths": { "src/*": ["./src/*"] } }, "include": [ "src", ".eslintrc.cjs", "next-env.d.ts", "src/**/*.mts", "src/**/*.mjs", "src/**/*.ts", "src/**/*.tsx", ".next/types/**/*.ts" ] } pls 🧠 let me know what could i do 2 run the github.ts file whitout problems 😃
mukomo
mukomo5mo ago
I thought you couldn't directly run typescript files from npm without a workaround
bigciri
bigciri5mo ago
did you try to remove "type":"module" from your config? i mean from package.json
upside_downside
upside_downside5mo ago
try npx tsx src/lib/github.ts
reptiloid
reptiloid5mo ago
You can't run .ts files using node. You need to transpile it first using tsc, but you are probably looking for something like tsx. You can run it using npx or install as a dev dependency and change the script to tsx ./src/lib/github.ts
Beyond^sight
Beyond^sightOP5mo ago
i ve done that
Beyond^sight
Beyond^sightOP5mo ago
also tried with "github": "npx tsx src/lib/github.ts",
No description
mukomo
mukomo5mo ago
Try this instead of npm run github
Beyond^sight
Beyond^sightOP4mo ago
📝 Update : Have installed the npx into the app then the github command has worked, ready to move foward, appreciate y all suport ❤️

Did you find this page helpful?