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

349
Views
export default was not found; module export not working

with encore webpack, I do add a js file:

Encore
.addEntry('js/request', './assets/js/request.js')
.cleanupOutputBeforeBuild()
.disableSingleRuntimeChunk()
.splitEntryChunks()
...

Inside the request.js, I import a custom module:

import Request from './request';

console.log(Request);
window.Request = Request;

Which is exported in request/index.js:

export default () => ({
    url: null,
    options: { method: 'GET' },
    response: null,
    load() {
        ...

Pretty straight forward actually. BUT - when I compile this, I get a warning:

warning in ./assets/js/request.js

"export 'default' (imported as 'Request') was not found in './request'

And undefined is logged for that console.log(Request); command.

Usually this happens, when you don't export as default but I do and somehow don't? This doesn't make sense at all for me. I'm pretty new to webpack and couln't find a helpful hint so far...

Anyone an idea what I'm doing wrong?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Oh man, I've put a request.js and a request/index.js into the same folder. So when I import ./request inside request.js, its gonna import itself due to the hierarchy of the import file detection.

Now I will just put all the files into a separate folder /entries and will be able to import ../request. Importing explicitly import ./request/index.js will also work.

I guess this just has to happen once, when you start with modules, webpack and stuff...

about 4 years ago · Santiago Gelvez 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!