question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: pubnub_1.default is not a constructor

See original GitHub issue

I’m not sure this issue is related to pubnub or ts-node, but when I use pubnub with ts-node together, it will throw out the following error:

TypeError: pubnub_1.default is not a constructor

My code is:

import Pubnub from "pubnub"
const pubnub = new Pubnub({
  subscribeKey: "sub-c-52a9ab50-291b-11e5-baaa-0619f8945a4f"
})

And my tsconfig.json is:

{
  "compilerOptions": {
    "strict": true,
    "lib": ["es6"],
    "typeRoots": [
      "./node_modules/@types/",
      "./src/@types/"
    ]
  }
}

I’ve already installed types for pubnub,

npm install pubnub --save
npm install @types/pubnub --save-dev

I guess I need to change some configurations in tsconfig.json, any ideas?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
NaridaLcommented, Jan 24, 2018

The correct import is import pubnub = require('pubnub').

2reactions
KhanhPham2411commented, Nov 7, 2021

Image Just add this setting in your ts.config "esModuleInterop": true,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: *.default is not a constructor - Stack Overflow
I get the following error, when testing some javascript code, transpiled from a typescript file. Here is the error: Error: _mapAction2.default ...
Read more >
TypeError: web3_1.default is not a constructor
I'm trying to convert a DApp that uses web3.js from JavaScript to TypeScript, but I have encountered a bunch of runtime errors. I'm...
Read more >
Hi, to fix this `o.default is not a constructor`, you need to adjust ...
Hi, to fix this `o.default is not a constructor`, you need to adjust your import statement, from: import Cookies from 'universal-cookie';.
Read more >
TypeError: _gauge2.default is not a constructor - Laracasts
I'm trying to wrap this gauge http://bernii.github.io/gauge.js/ in a Vue component, but Vue gives me the error: TypeError: _gauge2.default is not a ......
Read more >
colyseus_js__WEBPACK_IMPO...
BattleScreen.js:16 Uncaught TypeError: colyseus_js__WEBPACK_IMPORTED_MODULE_1___default.a is not a constructor. any thoughts? Reply Quote.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found