How to Fix "Lazerpay is not a constructor" Node SDK Error
Quickly Resolve Lazerpay SDK Import Error
Table of contents
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
In this guide, I want to document how you can resolve it.
** Note:**
I have the0.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.
ย