---
title: "TypeScript Exports Module for Node.js"
date: 2022-09-01T15:27:41.000Z
author: Z.SHINCHVEN
tags: [TypeScript, Node.js, RequireJS]
canonical: https://atlassc.net/2022/09/02/typescript-exports-module-for-nodejs
---
## Long Story Short

```TypeScript
const func = () => {
    console.log('Hello World');
}

// Export for TypeScript module system
export default func;

// Export for Node.js module system, by doing this you can use `require` to import the module in Node.js 
if (typeof module !== 'undefined') {
    module.exports = Object.assign(func, module.exports)
}
```
