Expected Behavior
I have a strange problem with ts and nodejs It was totally fine but now I get the following error when trying running the command node src/index.ts
I got this error Unknown file extension node:internal/process/esm_loader:74 internalBinding('errors').triggerUncaughtException( ^ TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
anyway I can run the index.ts using nodemon but cannot run it using node or even running the index.js file.
this is my json package
"main": "src/index.ts",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rm -rf dist && tsc",
"setup": "npm install && npm update",
"start:dev": "NODE_ENV=development nodemon src/index.ts",
"start": "node src/index.ts",
"start:prod": "npm run build && NODE_ENV=production node dist/index.js"
},
- ts-node version:
ts-node v9.1.1
node v15.11.0
compiler v4.0.7
tsconfig file
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
- Operating system and version: using mac os big sur
Expected Behavior
I have a strange problem with ts and nodejs It was totally fine but now I get the following error when trying running the command
node src/index.tsI got this error
Unknown file extension node:internal/process/esm_loader:74 internalBinding('errors').triggerUncaughtException( ^ TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"anyway I can run the index.ts using nodemon but cannot run it using node or even running the index.js file.
this is my json package
ts-node v9.1.1
node v15.11.0
compiler v4.0.7
tsconfig file