create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Typescript -> ReferenceError: exports is not defined

Open InputNeuron opened this issue 7 years ago • 2 comments

Is this a bug report?

yes

... followed the instructions for converting to TS and they don't work.

I get "ReferenceError: exports is not defined"

Tried restarting the dev server ... that doesn't work.

Let it create its own tsconfig.json and that didn't work either.

InputNeuron avatar Dec 14 '18 23:12 InputNeuron

Hi @burtonator, interesting. A colleague of mine did the same thing this week and didn't have any issues, so I'm inclined to believe this might be something within your project.

Can you please share your project? Or an example repository for reproduction?

If you have exports in your code, that should be export - but otherwise, we'll need to have a look at the code to understand the exact problem sorry.

mrmckeb avatar Dec 15 '18 07:12 mrmckeb

I had the same problem, had to add export = null at the bottom of my index.tsx because TS generates code using Object.defineProperty(exports.default) or something like that, and exports isn't defined. Adding the export = null replaces the code with module.exports = null instead so no error!

ArcticZeroo avatar Dec 21 '18 15:12 ArcticZeroo