TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension “.ts” for S:projectssofierethink-backendsrcmaintypescriptutilsCalculateAge.ts
I was trying to run this file using the command ts-node, then I got this error. I’d installed ts-node via npm, so I don’t know why the error still occured.
Can code files with a .cts extension in Node.js use module syntax for imports and exports?
I created a new Node.js project with Node version 18.15.0. In the package.json, I added the field “type”: “module”. { “name”: “ts-node-test”, “version”: “1.0.0”, “description”: “”, “type”: “module”, “scripts”: { “test”: “cross-env NODE_OPTIONS=”–loader ts-node/esm” node index.cts” }, “author”: “”, “license”: “ISC”, “devDependencies”: { “cross-env”: “^7.0.3”, “ts-node”: “^10.9.2”, “tslib”: “^2.6.2”, “typescript”: “^5.4.5” }, “volta”: { “node”: […]
why .cjs extension file can use import and export statements
I created a new Node.js project with Node version 18.18.2. In the package.json
, I added the field "type": "module"
.
What changes introduced since nodejs 18.19 that cause ts-node fails to work with the error “ERR_UNKNOWN_FILE_EXTENSION”
What changes introduced since nodejs 18.19 that cause ts-node fails to work with the error TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension “.ts”?