CodexBloom - Programming Q&A Platform

scenarios 'scenarios: Invalid character in identifier' when using ES Modules in Node.js 16 with TypeScript

👀 Views: 931 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-15
node.js typescript esm TypeScript

I'm working with an scenario with using ES modules in my Node.js application that is written in TypeScript. While trying to import a module using the syntax `import { myFunction } from './myModule.js';`, I am getting an behavior: `behavior: Invalid character in identifier`. I have ensured that my `tsconfig.json` is configured properly with the following settings: ```json { "compilerOptions": { "module": "ESNext", "target": "ESNext", "moduleResolution": "Node", "esModuleInterop": true, "outDir": "dist", "rootDir": "src" } } ``` When I run my TypeScript files using `ts-node` (version 10.0.0), the behavior occurs. I have also tried renaming the file to `myModule.ts` and importing it as `import { myFunction } from './myModule';`, but I still receive the same behavior message. Additionally, I checked my Node.js version, and I am running Node.js 16.13.0, which should support ES modules. Is there a specific reason why this behavior is being thrown, and how can I resolve it? Any insights or suggestions would be greatly appreciated!