chalk/strip-ansi

The issue has been closed
Error when starting a ts program in ts-node #38
justmedev posted onGitHub
I've made a mini JS program and started to migrate it to TS.
Code:
import chalk from 'chalk';
import stripAnsi from 'strip-ansi';
...
TSconfig:
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"allowJs": true, /* Allow javascript files to be compiled. */
"outDir": "./build", /* 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'. */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
Error:
Error: Must use import to load ES Module: C:\Users\ilja\Desktop\Projects\Development\Other\Plugins\steam-cloud-sync\node_modules\strip-ansi\index.js
require() of ES modules is not supported.
require() of C:\Users\ilja\Desktop\Projects\Development\Other\Plugins\steam-cloud-sync\node_modules\strip-ansi\index.js from C:\Users\ilja\Desktop\Projects\Development\Other\Plugins\steam-cloud-sync\src\logger.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES mo
dules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\ilja\Desktop\Projects\Development\Other\Plugins\steam-cloud-sync\node_modules\strip-ansi\package.json.
at new NodeError (node:internal/errors:370:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:13)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:816:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (C:\Users\ilja\Desktop\Projects\Development\Other\Plugins\steam-cloud-sync\src\logger.js:43:36)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
at Module.load (node:internal/modules/cjs/loader:975:32)