Skip to content

TypeError: "not a constructor" when using TypeScript #83

Description

@danbockapps

I get this error when using the example code at the top of index.d.ts:

Users-MacBook-Pro:twitter-lite-test danbock$ ts-node dev.ts 

/Users/danbock/code/twitter-lite-test/dev.ts:3
const twitter = new Twitter({
                ^
TypeError: twitter_lite_1.Twitter is not a constructor
    at Object.<anonymous> (/Users/danbock/code/twitter-lite-test/dev.ts:3:17)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Module.m._compile (/Users/danbock/.nvm/versions/node/v12.16.2/lib/node_modules/ts-node/src/index.ts:836:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/danbock/.nvm/versions/node/v12.16.2/lib/node_modules/ts-node/src/index.ts:839:12)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at main (/Users/danbock/.nvm/versions/node/v12.16.2/lib/node_modules/ts-node/src/bin.ts:226:14)
    at Object.<anonymous> (/Users/danbock/.nvm/versions/node/v12.16.2/lib/node_modules/ts-node/src/bin.ts:485:3)

I reproduced this on a blank project. Just ran npm install twitter-lite and copied this code into a blank file and ran it using ts-node. Got the same error.

import { Twitter } from 'twitter-lite';

const twitter = new Twitter({
 consumer_key: 'XYZ',
 consumer_secret: 'XYZ',
 access_token_key: 'XYZ',
 access_token_secret: 'XYZ'
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions