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.

Cannot find module 'request'

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When I run Jest, it fails immediately with Cannot find module 'request', but I don’t require request myself, it’s part of the Jest dependency tree.

λ npm test -- --no-cache

> nima-bot@0.0.1 test C:\Users\E\Documents\GitHub\nima
> jest "--no-cache"

 FAIL  src\__tests__\modules\calc.js
  ● Test suite failed to run

    Cannot find module 'request'

      at node_modules/request-promise-native/lib/rp.js:8:12
      at module.exports (node_modules/stealthy-require/lib/index.js:62:23)
      at Object.<anonymous> (node_modules/request-promise-native/lib/rp.js:7:15)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.238s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

I’ve pushed a branch named wtf-jest to a branch that you can test it out on: https://github.com/denizdogan/nima/tree/wtf-jest

git clone -b wtf-jest https://github.com/denizdogan/nima
cd nima
yarn i
yarn test

What is the expected behavior?

I expect Jest to run my test suites.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

NPM 5.6.0 Node.js 9.4.0 Jest 22.1.4 Windows 10 (64-bit)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

23reactions
SimenBcommented, Jan 20, 2018

Something is up with your installed tree, doing npm dedupe && npm prune && npm install makes the test green.

Also, you should install the babel core bridge if you’re using babel 7 (see https://facebook.github.io/jest/docs/en/getting-started.html#additional-configuration)

3reactions
nikolay-borzovcommented, Jul 17, 2020

I had the same problem. npm list request said UNMET PEER DEPENDENCY request@2.88.2. Calling npm i -D jest fixed the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js: cannot find module 'request'
Go to directory of your project mkdir TestProject cd TestProject. Make this directory a root of your project (this will create a default...
Read more >
Fix - Cannot find module 'request' error in Node.js
The can't find module request error occurs, if you're trying to access a request module that is not currently installed in your project....
Read more >
Error: Cannot find module 'request' · Issue #2788
sudo npm install --save request -g node > var request = require('request'); Error: Cannot find module 'request' at Function.Module.
Read more >
browserify with firebase+express (Error: Cannot find ...
Error: Cannot find module 'request'. I am pretty new to browserify/express, so I could be doing something silly. Am I missing an import...
Read more >
[Solved]-Node.js Error: Cannot find module 'request'
Something looks wrong in your directory structure. I would nuke the node_modules directory and redo the npm command. It's always a good idea...
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