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

323
Views
how can I use npm "debug" package with es modules

this is how I used to used it in common modules.

const debuger=require('debug')("namespace")

I set an environmental variable DEBUG="namespace" and when i start the app, i can use the debugger.

However I could not figure out how to use it with import/export staments.

  import debugger from "debug" // how can i pass () here
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can do:

import debug from 'debug';
const logger = debug('namespace');
logger('Starting App');

Actually, as the npm debug module exports a function directly (module.exports = (params) => {...), you can give the function whatever name you like, for example:

import createDebugMessages from 'debug';
const debug = createDebugMessages('namespace');
debug('Starting App');

This way, the original syntax for debugging does not even need to be changed.

over 4 years ago · Santiago Trujillo 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!