# HubSpot Library in Typescript and esModuleInterop

**URL:** <https://community.hubspot.com/t/hubspot-library-in-typescript-and-esmoduleinterop/29638>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, sdk\
**Created:** [January 3, 2021, 10:10pm UTC](https://community.hubspot.com/t/hubspot-library-in-typescript-and-esmoduleinterop/29638 "2021-01-03T22:10:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PCarlson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pcarlson/32/35493_2.png) [@PCarlson](https://community.hubspot.com/u/PCarlson)\
**Post date:** [January 3, 2021, 10:10pm UTC](https://community.hubspot.com/t/hubspot-library-in-typescript-and-esmoduleinterop/29638/1 "2021-01-03T22:10:58Z")

</div>

In case it helps someone else, I was getting many errors running tsc with the hubspot nodejs library like:

```lia-code-sample
node_modules/@hubspot/api-client/lib/codegen/cms/audit_logs/api/defaultApi.d.ts:13:8 - error TS1192: Module '"http"' has no default export.

13 import http from 'http';

```

and

`./node_modules/@hubspot/api-client/lib/codegen/cms/audit_logs/model/models.d.ts:7:8 - error TS1259: Module '"/home/philc/node_projects/fut-skills/hubspot/node_modules/@types/request/index"' can only be default-imported using the 'esModuleInterop' flag`

I was able to resolve this by modifying my tsconfig.json file to add the compiler option esModuleInterop so it looked like this:

```lia-code-sample
{
 "compilerOptions": {
 "module": "commonjs",
 "target": "es6",
 "sourceMap": true,
 "outDir": "./dist",
 "strict": true,
 "noUnusedLocals": true,
 "esModuleInterop": true,
 },
 "include": [
 "app.ts",
 "config.ts",
 "types.ts",
 "src/**/*",
 "lib/**/*"
 ],
 "exclude": ["./node_modules"]
}

```

Phil

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [January 4, 2021, 5:02pm UTC](https://community.hubspot.com/t/hubspot-library-in-typescript-and-esmoduleinterop/29638/2 "2021-01-04T17:02:50Z")

</div>

@PCarlson

Thank you for adding this for others to see!

---

<div class="post-metadata">

**Author:** ![PCarlson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pcarlson/32/35493_2.png) [@PCarlson](https://community.hubspot.com/u/PCarlson)\
**Post date:** [January 17, 2021, 8:54pm UTC](https://community.hubspot.com/t/hubspot-library-in-typescript-and-esmoduleinterop/29638/3 "2021-01-17T20:54:20Z")

</div>

I’m just posting a simple reply so I can mark this as solved.

The solution to esModuleInterop errors reported by tsc for the HubSpot API library files is to add **“esModuleInterop”: true** to tsconfig.json under the **“compilerOptions”:** block. See the original post for sample content.

Phil

---

<div class="post-metadata">

**Author:** ![DFall9](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@DFall9](https://community.hubspot.com/u/DFall9)\
**Post date:** [February 8, 2024, 6:53am UTC](https://community.hubspot.com/t/hubspot-library-in-typescript-and-esmoduleinterop/29638/4 "2024-02-08T06:53:39Z")

</div>

Hi,

Sorry to say that that workaround does not solve the problem for everyone. Library authors should not use **esModuleInterop: true** as you are forcing consumers of your package to change their tsconfig.  
Please fix this

Thx
