2

For some strange reason, Webpack incorrectly attempts to import named imports as default. I noticed the problem when I tried to build my project in a docker container. I got the following error: enter image description here

I also tried building the project directly on my mac and it was initially built successfully. But after deleting my node_modules folder and running npm install afresh, my project stopped compiling. It started to throw the same error:

enter image description here

My package.json file didn't change in any way and all my packages have fixed (exact) versions. I've tried updating babel and all its plugins and even tried to build the last commit that successfully built two weeks ago but all to no avail.

I still can't understand why my project won't compile anymore if absolutely nothing changed. Did something change on the npm registry?

Is anyone else experiencing a similar problem? Any ideas on how to solve it?

Innocent
  • 21
  • 3
  • What's your webpack configuration look like? Can you post it somewhere? – cjones26 Feb 26 '21 at 18:08
  • Sure, here it is. https://gist.github.com/ochesaint/0706c38cd67d8aa07d5e51689df45756 – Innocent Feb 26 '21 at 18:11
  • FYI you are not the only one experiencing this: https://stackoverflow.com/questions/66331991/attempted-import-error-default-is-not-exported-from-assertthisinitialized. Seems to be an upstream bug somewhere. – cjones26 Feb 26 '21 at 18:16
  • The answers provided there weren't helpful to me. :( – Innocent Feb 26 '21 at 18:20
  • @cjones26 Did you see anything off in my webpack config? Although, the same config worked 2 weeks ago. I even tried rebuilding the same changes from two weeks ago but it's unsuccessful. Maybe some problem with docker? I've tried various versions on node in my docker config (setup) but all to no avail. – Innocent Feb 26 '21 at 18:33
  • If you are using semver in your package.json, I suspect that a package was released with this bug in the past 2 weeks. To avoid this sort of thing (as well as avoiding security issues) I DO NOT recommend using semver in your package.json. I doubt this has anything to do with docker at all and something more to do with an NPM package. – cjones26 Feb 26 '21 at 19:24
  • 1
    @cjones26 I doubt this has anything to do with semver since all the packages in package.json use exact (fixed) versions. I even tried to rebuild the exact commit that successfully built two weeks ago, but this time it's failing. I'm wondering if others eexpriencing the same problem are also using docker, but I can't comment on the question you linked (in order to ask them) since I don't have enough reputation here. – Innocent Feb 26 '21 at 20:02
  • @Innocent--silly question but did you completely remove node_modules and package-lock.json before building and deploying into the container? – cjones26 Feb 26 '21 at 20:44
  • @cjones26 yes I did – Innocent Feb 26 '21 at 21:19

0 Answers0