I keep getting;TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Project/src/index.ts when I run npm run dev
All my settings are as recommended,
My package.json
{
"name": "api",
"version": "0.0.1",
"description": "",
"type":"commonjs",
"scripts": {
"start": "NODE_ENV=production node build/index.js",
"dev": "nodemon src/index.ts",
},
"dependencies": {
"@cloudinary/url-gen": "^1.9.1",
"bcrypt": "^5.0.1",
"body-parser": "^1.20.0",
"cloudinary": "^1.34.0",
"cors": "^2.8.5",
"date-fns": "^2.29.3",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"express-rate-limit": "^6.7.0",
"joi": "^17.6.0",
"jsonwebtoken": "^8.5.1",
"multer": "^1.4.5-lts.1",
"nodemailer": "^6.9.1",
"pg": "^8.4.0",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.3.17"
},
"devDependencies": {
"@types/bcrypt": "^5.0.0",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/jsonwebtoken": "^8.5.8",
"@types/node": "^16.11.38",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"nodemon": "^2.0.16",
"ts-node": "^10.9.1",
"typescript": "4.5.2"
},
"engines": {
"node": "18.10.0"
}
}
My tsconfig.json
{
"compilerOptions": {
"lib": ["es5", "es6"],
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./build",
"rootDir": "./src",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"esModuleInterop": true
},
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
},
"include": ["/**/*.ts"],
"exclude": ["node_modules"]
}
I dont understand what im doing wrong I tried most of the fixes i found online but most i had already implemented them.
Nodemon don't understand
tsfiles. Monitor the build folderjsfiles.If you want to run Nodemon on
tsfile changes use theTypescript compiler (TSC)you have installed. TSC with watch flag, from shell docs.like so:
Run
compilebeforedev.Any changes in your
tsfiles will dispatch a build, putting thejsfiles under the configuredbuildfolder, and making nodemon act.