Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
TypeError: bn_js_1.default is not a constructor

Hello everone, i just implement bn.js in class validator DTO. And got some error like this:

TypeError: bn_js_1.default is not a constructor at Object.transformFn

anyone can help me? here's the DTO:

import BN from 'bn.js';
import { Transform } from 'class-transformer';

export class IWCreateNftCollectionV1ReqDTO {
  @Transform(({ value }) => new BN(value.toString()))
  royalties:BN;
}

And the package.json

"dependencies": {
    "@types/bn.js": "^5.1.0",
    "bn.js": "^5.2.0"
}

Thanks

UPDATE Solved by adding bellow in tsconfig.json

{
  "compilerOptions": {
    ...
    "esModuleInterop": true,
  },
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Seem like bn.js doesn't use default exports. You can either set esModuleInterop: true in your tsconfig, or you should be able to do import * as BN from 'bn.js'; if you don't want to modify that setting

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!