I am currently facing an issue while trying to execute a script that consists of two .ts files in a regular folder. One file contains the script, and the other has helper functions required to run it. Additionally, I am importing external libraries such as axios and form-data.
However, when I attempt to run the script using ts-node: node script.ts, an error message is displayed:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
Here is a snippet of my package.json:
{
"dependencies": {
"@types/node": "^17.0.23",
"axios": "^0.26.1",
"form-data": "^4.0.0",
"showdown": "^2.0.3",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
},
"type": "module"
}
Furthermore, my tsconfig.json configuration is as follows:
{
"compilerOptions": {
"esModuleInterop": true
},
"include": ["/**/*.ts"],
"exclude": ["node_modules"]
}
The import statements in the script.ts file are:
import { datoManagementPrimaryEnvironment } from "./content.management";
import {
createContent,
uploadToCloudfare,
getEntryFromDatoWithTheId,
getFilters,
} from "./helpers";
and in helpers.ts:
import { datoManagementPrimaryEnvironment } from "./content.management";
import axios from "axios";
import FormData from "form-data";
var showdown = require("showdown");
If anyone has any insights on what might be causing this issue, I would greatly appreciate your help. Thank you!