twiliotwilio-node

Twilio 'Header' import issue


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


Solution

  • 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.