How to fix ReferenceError: Document is not defined in JavaScript

How to fix ReferenceError: Document is not defined in JavaScript