NPM error on running npm run test
See original GitHub issueWhen running “npm run test” in my project, browser-image-compression gives the following error:
(node:5212) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘createElement’ of undefined
at new file (\node_modules\jsdom\lib\jsdom\browser\Window.js:374:34)
at file (\node_modules\browser-image-compression\lib\utils.js:66:5)
at new Promise (<anonymous>)
at img (\node_modules\browser-image-compression\lib\utils.js:66:5)
at \node_modules\browser-image-compression\lib\utils.js:124:11
(node:5212) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:5212) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
events.js:288
throw er; // Unhandled ‘error’ event
^
Error: EPERM: operation not permitted, lstat ‘\node_modules\browser-image-compression\dist\browser-image-compression.d.ts’ Emitted ‘error’ event on NodeWatcher instance at: e_watcher.js:306:14) at callback (\node_modules\graceful-fs\polyfills.js:295:20) at FSReqCallback.oncomplete (fs.js:166:21) {
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:5 (1 by maintainers)
Top GitHub Comments
Same issue here.
I think it’s somehow related to https://stackoverflow.com/questions/48642733/jest-with-jsdom-document-is-undefined-inside-promise-resolve
jsdom
doesn’t work well inside Promise.I switched back to
v1.0.9
and it has no issue.@paulcustance-al I’ve just encountered the same issue and the only ‘work-around’ I’ve found it to install v1.0.9 instead.
Something must have changed since then but it is difficult to figure out exactly what without access to the source.