{"id":16841653,"url":"https://github.com/kevinpollet/typescript-es-modules-node-example","last_synced_at":"2025-06-12T17:32:53.966Z","repository":{"id":42209178,"uuid":"183170833","full_name":"kevinpollet/typescript-es-modules-node-example","owner":"kevinpollet","description":"ES Modules written in TypeScript running on Node.js","archived":false,"fork":false,"pushed_at":"2022-12-09T00:42:01.000Z","size":1343,"stargazers_count":24,"open_issues_count":13,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T04:04:05.888Z","etag":null,"topics":["es-modules","esnext","example","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinpollet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-24T07:16:32.000Z","updated_at":"2023-07-02T08:10:42.000Z","dependencies_parsed_at":"2023-01-25T08:35:20.518Z","dependency_job_id":null,"html_url":"https://github.com/kevinpollet/typescript-es-modules-node-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kevinpollet/typescript-es-modules-node-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinpollet%2Ftypescript-es-modules-node-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinpollet%2Ftypescript-es-modules-node-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinpollet%2Ftypescript-es-modules-node-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinpollet%2Ftypescript-es-modules-node-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinpollet","download_url":"https://codeload.github.com/kevinpollet/typescript-es-modules-node-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinpollet%2Ftypescript-es-modules-node-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259512366,"owners_count":22869394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es-modules","esnext","example","nodejs","typescript"],"created_at":"2024-10-13T12:42:38.541Z","updated_at":"2025-06-12T17:32:53.931Z","avatar_url":"https://github.com/kevinpollet.png","language":"TypeScript","readme":"# Running TypeScript ES Modules with Node.js\n\n[![Build Status](https://github.com/kevinpollet/typescript-es-modules-node-example/workflows/Build/badge.svg)](https://github.com/kevinpollet/typescript-es-modules-node-example/actions)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)\n\nBased on the [Announcing a new experimental modules](https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff) post from the Node team, this repository is an example of a TypeScript app running with the new `experimental modules` feature shipped with Node.js 12. As explained in the linked post, it's now possible to use `import` and `export` syntax in `.js` files, so ES Modules transpiled from TypeScript can be used out of the box 😎\n\n## Project tree\n\n```\n.\n├── lerna.json\n├── package-lock.json\n├── package.json\n├── packages\n│   ├── app //--\u003e TypeScript app transpiled as an ES Module, using es-module dependency\n│   │   ├── package-lock.json\n│   │   ├── package.json\n│   │   └── tsconfig.json\n│   └── es-module //--\u003e ES Module written in TypeScript\n│       ├── package-lock.json\n│       ├── package.json\n│       └── tsconfig.json\n└── tsconfig.settings.json\n```\n\n## Config\n\n### Node.js\n\n- `type: module`: New package.json field to treat all `.js` files in project as ES Modules, see [app](./packages/app/package.json) and [es-module](./packages/es-module/package.json) files.\n- `--experimental-modules`: Flag to enable new experimental modules feature.\n- `--es-module-specifier-resolution=node`: By default, file extensions are mandatory in import. This flag enable CommonJS-style automatic extension resolution behavior. This flag is required because [TypeScript does not add imported file extension in transpiled code](https://github.com/microsoft/TypeScript/issues/16577).\n\n### TypeScript\n\n- `module: \"esnext\"`: Set the module code generation to `esnext`, see inherited [tsconfig.settings.json](./tsconfig.settings.json)\n\n## Run app\n\n1. Install [Node.js 12](https://nodejs.org/en/blog/release/v12.0.0/) or type `nvm use` if you use [nvm](https://github.com/creationix/nvm)\n2. Install project dependencies with: `npm install`\n3. Start app with: `npm run start`\n4. Browse http://localhost:3000\n\nYou should see the following JSON response:\n\n```json\n{\n  \"messages\": [\"Hello from ES Module dependency\", \"Hello from local ES Module\"]\n}\n```\n\n## License\n\n[MIT](./License.md) © kevinpollet\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinpollet%2Ftypescript-es-modules-node-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinpollet%2Ftypescript-es-modules-node-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinpollet%2Ftypescript-es-modules-node-example/lists"}