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

213
Views
How can I export all my named exports in a default object?

I can do:

import fs from 'fs'
//now use fs normally
fs.open('file')

But I can't do the same with the modules I write:

import myModule from 'myModule'
       ^^^^^^^^
SyntaxError: The requested module 'myModule' does not provide an export named 'default'

I am forced to do:

import * as myModule from 'myModule'
//now use myModule normally
myModule.do_something()

Is it possible to automatically export all the named exports in the default one so that it's not required to import * as?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you cannot export multiple default exports. use named exports instead.

example here is the exported modules from a file named Test.js:

export const namedVar = "named1";

export const do_something = () => console.log("do something");

you can use it this way:

import { namedVar, do_something } from './Test'

console.log(namedVar);
console.log(do_something());
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!