1

When i installed latest twilio's version which is "twilio": "^4.7.2", and building the project (npm run build) the following error occurs,

node_modules/twilio/lib/base/BaseTwilio.d.ts:22:19 - error TS2304: Cannot find name 'Headers'.

22         headers?: Headers;
                     ~~~~~~~


Found 1 error in node_modules/twilio/lib/base/BaseTwilio.d.ts:22

My node version : v16.18.1

Npm version : v8.19.2

Joe Kee
  • 13
  • 4
  • Can you add more details on your machine or maybe try it on another system? I just tested it on my machine with v16.18.0 (npm v8.19.2) and I could install "^4.7.2" – IObert Feb 13 '23 at 11:44
  • npm version : 8.19.2 – Joe Kee Feb 13 '23 at 13:22
  • node version : 16.18.1 – Joe Kee Feb 13 '23 at 13:24
  • @IObert I can also able to install but while building the project using `npm run build` i am getting the above error – Joe Kee Feb 13 '23 at 13:26
  • Can you please add more information about the kind of project you try to build? Please add instructions how to reproduce this issue too. – IObert Feb 13 '23 at 14:02
  • Its a Node service project. – Joe Kee Feb 14 '23 at 08:11
  • To reproduce this issue : Install twilio's latest version and try to call any one of its API – Joe Kee Feb 14 '23 at 08:13
  • Please provide full instructions with a code snippet in your original question. – IObert Feb 14 '23 at 08:38
  • I've got the same issue. The project can't be built. This is what I get `node_modules/twilio/lib/base/BaseTwilio.d.ts(22,19): error TS2304: Cannot find name 'Headers'.` – Lab Lab Feb 16 '23 at 16:08
  • @IObert well you don't need any snippets. I guess the problem is in some typescript settings. I get the same error, but all I did is just install twilio of the same version – Lab Lab Feb 16 '23 at 16:17
  • I am seeing this issue as well in a node express environment. Hacking with `skipLibCheck` is not the right solution. – sebastian Feb 28 '23 at 17:09

1 Answers1

1

I got the same issue once I installed the twilio npm package of the exact same version ^4.7.2. I'm assuming it's some typescript compilation issue. And there is a trick that you can use to make it work.

Add this in your tsconfig.json:

{
    "compilerOptions": {
        "skipLibCheck": true,
    }
}

This will solve your issue, but don't consider it as a fix. It's rather workaround. P.S. This will also speed up your overall typescript compilation process.

Lab Lab
  • 781
  • 10
  • 34