Babel 7 Upgrading creating error: "TypeError: Cannot assign to read only property 'exports' of object '#<Object>'"

Viewed 10308

I'm in the process of upgrading from babel 6 to babel 7. Some of my old tests using chai, sinon, and enzyme come up with the following error:

TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

I do have some code that is using "require" instead of "export" and I know that the babel 7 documentation says that you might need to use "require().default" instead. But that doesn't seem to be helping.(Or I just need to finish putting defaults everywhere and calling them before any the errors will go away). Does anyone else have experience with this issue?

1 Answers

Try not to mix require / module.exports and import / export, ensure to be consistent with one.

Related