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
> [email protected] 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)
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)
@SimenB Thanks, it works now. I think the docs are outdated with regards to babel-jest though, because 'babel-core@^7.0.0-0' is not found.
It works on my machine.
$ mkdir test
$ cd test
$ yarn init -y
$ yarn add babel-core@^7.0.0-0
success Saved 1 new dependency.
└─ [email protected]
@SimenB Maybe this is a difference between NPM and Yarn? Or maybe you had the package in your cache? This is what it looks like to me:
λ npm install --save-dev babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime
npm ERR! code E404
npm ERR! 404 Not Found: '[email protected]'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\E\AppData\Roaming\npm-cache\_logs\2018-01-20T19_01_52_963Z-debug.log
Debug log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'babel-jest',
1 verbose cli '\'[email protected]\'',
1 verbose cli '@babel/core',
1 verbose cli 'regenerator-runtime' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: C:\Users\E/.npmrc. (matches userconfig)
5 verbose npm-session e3ba7b0abf481ecd
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 http fetch GET 200 https://registry.npmjs.org/regenerator-runtime 105ms
9 http fetch GET 200 https://registry.npmjs.org/babel-jest 110ms
10 silly pacote tag manifest for regenerator-runtime@latest fetched in 118ms
11 silly pacote tag manifest for babel-jest@latest fetched in 121ms
12 http fetch GET 404 https://registry.npmjs.org/%27babel-core 918ms
13 silly fetchPackageMetaData error for '[email protected]' 404 Not Found: '[email protected]'
14 http fetch GET 200 https://registry.npmjs.org/@babel%2fcore 981ms
15 silly pacote tag manifest for @babel/core@latest fetched in 986ms
16 verbose stack Error: 404 Not Found: '[email protected]'
16 verbose stack at fetch.then.res (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
16 verbose stack at tryCatcher (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
16 verbose stack at Promise._settlePromiseFromHandler (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
16 verbose stack at Promise._settlePromise (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
16 verbose stack at Promise._settlePromise0 (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
16 verbose stack at Promise._settlePromises (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
16 verbose stack at Async._drainQueue (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
16 verbose stack at Async._drainQueues (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
16 verbose stack at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
16 verbose stack at runCallback (timers.js:756:18)
16 verbose stack at tryOnImmediate (timers.js:717:5)
16 verbose stack at processImmediate [as _immediateCallback] (timers.js:697:5)
17 verbose cwd C:\Users\E\Documents\GitHub\tmep
18 verbose Windows_NT 10.0.15063
19 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "babel-jest" "'[email protected]'" "@babel/core" "regenerator-runtime"
20 verbose node v9.4.0
21 verbose npm v5.6.0
22 error code E404
23 error 404 Not Found: '[email protected]'
24 verbose exit [ 1, true ]
Then I figured it might have to do with the apostrophes, so I tried without them:
λ npm install --save-dev babel-jest babel-core@^7.0.0-0 @babel/core regenerator-runtime
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\E\AppData\Roaming\npm-cache\_logs\2018-01-20T19_03_09_567Z-debug.log
Debug log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'babel-jest',
1 verbose cli '[email protected]',
1 verbose cli '@babel/core',
1 verbose cli 'regenerator-runtime' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: C:\Users\E/.npmrc. (matches userconfig)
5 verbose npm-session 4cd4e49ff8326c3f
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 http fetch GET 200 https://registry.npmjs.org/babel-core 144ms
9 silly registry:manifest no matching version for [email protected] in the cache. Forcing revalidation
10 http fetch GET 304 https://registry.npmjs.org/regenerator-runtime 142ms (from cache)
11 http fetch GET 304 https://registry.npmjs.org/babel-jest 146ms (from cache)
12 silly pacote tag manifest for regenerator-runtime@latest fetched in 151ms
13 silly pacote tag manifest for babel-jest@latest fetched in 155ms
14 http fetch GET 304 https://registry.npmjs.org/babel-core 33ms (from cache)
15 silly fetchPackageMetaData error for [email protected] No matching version found for [email protected]
16 http fetch GET 304 https://registry.npmjs.org/@babel%2fcore 934ms (from cache)
17 silly pacote tag manifest for @babel/core@latest fetched in 941ms
18 verbose type version
19 verbose stack babel-core: No matching version found for [email protected]
19 verbose stack at pickManifest (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\npm-pick-manifest\index.js:65:11)
19 verbose stack at fetchPackument.then.packument (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\fetchers\registry\manifest.js:52:18)
19 verbose stack at tryCatcher (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
19 verbose stack at Promise._settlePromiseFromHandler (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
19 verbose stack at Promise._settlePromise (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
19 verbose stack at Promise._settlePromise0 (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
19 verbose stack at Promise._settlePromises (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
19 verbose stack at Async._drainQueue (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
19 verbose stack at Async._drainQueues (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
19 verbose stack at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
19 verbose stack at runCallback (timers.js:756:18)
19 verbose stack at tryOnImmediate (timers.js:717:5)
19 verbose stack at processImmediate [as _immediateCallback] (timers.js:697:5)
20 verbose cwd C:\Users\E\Documents\GitHub\tmep
21 verbose Windows_NT 10.0.15063
22 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "babel-jest" "[email protected]" "@babel/core" "regenerator-runtime"
23 verbose node v9.4.0
24 verbose npm v5.6.0
25 error code ETARGET
26 error notarget No matching version found for [email protected]
27 error notarget In most cases you or one of your dependencies are requesting
27 error notarget a package version that doesn't exist.
28 verbose exit [ 1, true ]
That's very odd.
$ npm cache clear --force
$ npm init -y
$ npm i -D babel-core@^7.0.0-0 --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/simen/.nvm/versions/node/v8.9.4/bin/node',
npm verb cli '/Users/simen/.nvm/versions/node/v8.9.4/bin/npm',
npm verb cli 'i',
npm verb cli '-D',
npm verb cli 'babel-core@^7.0.0-0',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session b1d0b0c362b122f1
npm http fetch GET 200 https://registry.npmjs.org/babel-core 424ms
npm verb correctMkdir /Users/simen/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /Users/simen/.npm/_locks/staging-3b7229d1667142d2.lock for /Users/simen/Development/ugh/node_modules/.staging
http fetch GET 200 https://registry.npmjs.org/babel-core/-/babel-core-7.0.0-bridge.0.tgz 199ms7229d1667142d2.lock for /Users/simen/Development/ugh/node_modules/.staging
npm info lifecycle [email protected]~preinstall: [email protected]
npm info linkStuff [email protected]
npm verb linkBins [email protected]
npm verb linkMans [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm verb unlock done using /Users/simen/.npm/_locks/staging-3b7229d1667142d2.lock for /Users/simen/Development/ugh/node_modules/.staging
npm verb saving [ { name: 'babel-core',
npm verb saving spec: '^7.0.0-bridge.0',
npm verb saving save: 'devDependencies' } ]
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN [email protected] requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
+ [email protected]
added 1 package in 1.706s
npm verb exit [ 0, true ]
npm info ok
Strange indeed...! I can only install the bridge by explicitly stating -bridge.0:
C:\Users\E\Documents\GitHub\temp
λ npm cache clear --force
npm WARN using --force I sure hope you know what you are doing.
C:\Users\E\Documents\GitHub\temp
λ npm init -y
Wrote to C:\Users\E\Documents\GitHub\temp\package.json:
{
"name": "temp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
C:\Users\E\Documents\GitHub\temp ([email protected])
λ npm i -D babel-core@^7.0.0-0 --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'i',
npm verb cli '-D',
npm verb cli '[email protected]',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session b4335f89c3d8ee07
npm http fetch GET 200 https://registry.npmjs.org/babel-core 107ms
npm http fetch GET 304 https://registry.npmjs.org/babel-core 46ms (from cache)
npm verb type version
npm verb stack babel-core: No matching version found for [email protected]
npm verb stack at pickManifest (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\npm-pick-manifest\index.js:65:11)
npm verb stack at fetchPackument.then.packument (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\fetchers\registry\manifest.js:52:18)
npm verb stack at tryCatcher (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
npm verb stack at Promise._settlePromiseFromHandler (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
npm verb stack at Promise._settlePromise (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
npm verb stack at Promise._settlePromise0 (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
npm verb stack at Promise._settlePromises (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
npm verb stack at Async._drainQueue (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
npm verb stack at Async._drainQueues (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
npm verb stack at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\E\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
npm verb stack at runCallback (timers.js:756:18)
npm verb stack at tryOnImmediate (timers.js:717:5)
npm verb stack at processImmediate [as _immediateCallback] (timers.js:697:5)
npm verb cwd C:\Users\E\Documents\GitHub\temp
npm verb Windows_NT 10.0.15063
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "-D" "[email protected]" "--verbose"
npm verb node v9.4.0
npm verb npm v5.6.0
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\E\AppData\Roaming\npm-cache\_logs\2018-01-20T19_25_13_627Z-debug.log
C:\Users\E\Documents\GitHub\temp ([email protected])
λ npm i -D [email protected] --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Users\\E\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'i',
npm verb cli '-D',
npm verb cli '[email protected]',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session 1fc2bfa5ea3ed5cd
npm http fetch GET 304 https://registry.npmjs.org/babel-core 113ms (from cache)
npm verb correctMkdir C:\Users\E\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb lock using C:\Users\E\AppData\Roaming\npm-cache\_locks\staging-3405681582a677e8.lock for C:\Users\E\Documents\GitHub\temp\node_modules\.staging
npm http fetch GET 200 https://registry.npmjs.org/babel-core/-/babel-core-7.0.0-bridge.0.tgz 32ms
npm info lifecycle [email protected]~preinstall: [email protected]
npm info linkStuff [email protected]
npm verb linkBins [email protected]
npm verb linkMans [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm verb unlock done using C:\Users\E\AppData\Roaming\npm-cache\_locks\staging-3405681582a677e8.lock for C:\Users\E\Documents\GitHub\temp\node_modules\.staging
npm verb saving [ { name: 'babel-core',
npm verb saving spec: '^7.0.0-bridge.0',
npm verb saving save: 'devDependencies' } ]
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm notice created a lockfile as package-lock.json. You should commit this file.
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN [email protected] requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
+ [email protected]
added 1 package in 0.727s
npm verb exit [ 0, true ]
npm info ok
C:\Users\E\Documents\GitHub\temp ([email protected])
λ npm -v
5.6.0
C:\Users\E\Documents\GitHub\temp ([email protected])
λ node -v
v9.4.0
I can only guess a windows bug with npm... You can try opening up an issue with them?
I had the same problem. npm list request said UNMET PEER DEPENDENCY [email protected].
Calling npm i -D jest fixed the issue
Most helpful comment
Something is up with your installed tree, doing
npm dedupe && npm prune && npm installmakes 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)