ReferenceError: process is not defined
See original GitHub issueWhen trying to export an html node to image, I get the following erorr:
Error: Uncaught (in promise): ReferenceError: process is not defined
ReferenceError: process is not defined
Expected Behavior
I should get the node as a image
Current Behavior
Error
Possible Solution
The error is in the getPixelRatio
function:
const val = process && process.env ? process.env.devicePixelRatio : null
This may be fixed with a try catch like this:
let _process;
try {
_process = process;
} catch(){
}
const val = _process && _process.env ? _process.env.devicePixelRatio : null
Steps To Reproduce
Error Message & Stack Trace
Error: Uncaught (in promise): ReferenceError: process is not defined
ReferenceError: process is not defined
at getPixelRatio (util.js:99)
at index.js:40
at ZoneDelegate.invoke (zone-evergreen.js:364)
at Zone.run (zone-evergreen.js:123)
at zone-evergreen.js:857
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Zone.runTask (zone-evergreen.js:167)
at drainMicroTaskQueue (zone-evergreen.js:569)
at invokeTask (zone-evergreen.js:484)
at ZoneTask.invoke (zone-evergreen.js:469)
at resolvePromise (zone-evergreen.js:798)
at zone-evergreen.js:705
at rejected (tslib.es6.js:72)
at ZoneDelegate.invoke (zone-evergreen.js:364)
at Object.onInvoke (core.js:28237)
at ZoneDelegate.invoke (zone-evergreen.js:363)
at Zone.run (zone-evergreen.js:123)
at zone-evergreen.js:857
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:28225)
Additional Context
Your Environment
- html-to-image: 1.3.20
- OS: Windows 10
- Browser: Chrome 87
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
ReferenceError: “process is not defined” - GIMTEC
In this case, process is not defined in the browser environment, hence the error. The solution is to remove the reference to process...
Read more >javascript - Uncaught ReferenceError: process is not defined
I am using the command "npm start" which refers to the "start" script inside package.json that is set to "start": "http-server -a localhost...
Read more >"Uncaught ReferenceError: process is not defined" and the ...
The Uncaught ReferenceError: process is not defined happens when when a non-existent (here: process) variable is referenced .
Read more >process is not defined (NOT react-error-overlay ... - GitHub
Using the optional chaining operator with process ( process?.env ) throws a ReferenceError stating that process is not defined.
Read more >Uncaught ReferenceError: process is not defined
The error Uncaught ReferenceError: process is not defined may happen when the code tries to get access to the process object that provides ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@najmulansari while your fix can work, it’s a workaround and a fix/check should be made in the library and not by the client using it.
@injie997 I fixed this by adding below code in index.html page.
`
<script> var global = global || window; var Buffer = Buffer || []; var process = process || { env: { DEBUG: undefined }, version: [] }; </script>`