How to Fix "Lazerpay is not a constructor" Node SDK Error

Photo by Sigmund on Unsplash

How to Fix "Lazerpay is not a constructor" Node SDK Error

Quickly Resolve Lazerpay SDK Import Error

ยท

1 min read

While testing the Lazerpay Node SDK, I ran into this issue where the SDK throws this TypeError:Lazerpay is not a constructor error right after you instantiate the SDK.

Here's my code snippet

const Lazerpay = require('lazerpay-node-sdk');
const lazerpay = new Lazerpay(LAZER_PUBLIC_KEY, LAZER_SECRET_KEY);

// output
// Lazerpay is not a constructor

Here's a screenshot of the error

An Image showing the error "Lazerpay is not a contructor"

In this guide, I want to document how you can resolve it.

** Note:**
I have the 0.2.4 version of the SDK installed.

Resolving the Error

To resolve the error, you need to import the default module's export. I found the best explanation of the issue on StackOverflow. Give it a read.

So, change

const Lazerpay = require('lazerpay-node-sdk');

to

const Lazerpay = require('lazerpay-node-sdk').default;

And you should be good. The next version of the SDK will probably improve this. For now, here's a quick workaround.

Wrapping up

That should get you all patched up and one step closer to receiving Crypto Payments in your app.

Resource

  • The Lazerpay Forum Is the best place to get help and interact with the Coolest dudes on the block โ€” Lazer Humans.
ย