I'm getting the TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" error when i run my project.
I believe i configured my tsconfig.json correctly and i've been searching for hours but can't find a solution that works
tsconfig.json
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
"target": "ES2022",
"module": "ES2022",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "NodeNext" ,
"noEmit": true,
"allowImportingTsExtensions": true,
},
"ts-node": {
"esm": true
}
}
package.json
{
"main": "src/index.ts",
"type": "module",
"scripts": {
"dev": "nodemon src/index.ts"
},
"dependencies": {
...
},
"devDependencies": {
"@types/node": "^20.3.3",
"ts-node": "^10.9.1"
},
"overrides": {
"semver": "7.5.2"
}
}
run command npx ts-node src/index.ts