NodeJSTech

14.03.2021

NodeJS Module, getting ReferenceError: exports is not defined

Issues with ES Modules and CommonJS?

If you receive the following error while developing a NodeJS package

ReferenceError: exports is not defined

The solution could be to avoid adding this line to your package.json:

"type": "module"

You can read more about Modules, require, import , exports here:

https://nodejs.org/api/esm.html