question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPM error on running npm run test

See original GitHub issue

When 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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
lhz516commented, Oct 14, 2020

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.

1reaction
danielcrispcommented, Oct 5, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when running npm test or npm run lint-test #635 - GitHub
I tried to run my tests with the command javascript npm test . I went to the link provided by the CLI. Expected:...
Read more >
Error when I try to run `npm run test` in windows command ...
I tried to run npm run test on my directory but I get an error in the terminal that says: '.' is not...
Read more >
npm-run-script
Description. This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts.
Read more >
Problem to run tests with command 'npm run test' before code ...
Hi everyone Have a problem with test command Configuration version: 2.1 orbs: node: circleci/node@4.1.0 ... jobs: initial-check: docker: ...
Read more >
npm Scripts - LearnHowToProgram.com
... "scripts": { "test": "echo \"Error: no test specified\" && exit 1" } ... scripts refers to code that runs in the terminal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found