Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Module cache already has entry - /node_modules/yargs/build/lib/parse-command.js. #13008

Closed
bameyrick opened this issue Jul 11, 2022 · 7 comments · Fixed by #13211
Closed

Comments

@bameyrick
Copy link

Version

28.1.2

Steps to reproduce

  1. Clone https://github.com/bameyrick/iso-3166-1-flags-sprite-generator.git
  2. Checkout branch yargs
  3. Run npm i
  4. Run npm run fetch
  5. Run npm run test
  6. Tests will fail with the error:
 Module cache already has entry /iso-3166-1-flags-sprite-generator/node_modules/yargs/build/lib/parse-command.js. This is a bug in Jest, please report it!

      at invariant (node_modules/jest-runtime/build/index.js:2591:11)
          at async Promise.all (index 4)
          at async Promise.all (index 5)

Expected behavior

Jest should be able to run both sets of tests

Actual behavior

Module cache already has entry /iso-3166-1-flags-sprite-generator/node_modules/yargs/build/lib/parse-command.js. This is a bug in Jest, please report it! error thrown

Additional context

No response

Environment

System:
    OS: macOS 12.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  npmPackages:
    jest: ^28.1.2 => 28.1.2
@davidtaing
Copy link

I don't quite understand what's going on, but I was able to replicate this on my machine.

System:
    OS: Windows 10 10.0.19043 Build 19043
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    npm: 8.5.05- ~/.nvm/versions/node/v8.5.5/bin/npm
  npmPackages:
    jest: ^28.1.2 => 28.1.2

@mifi
Copy link

mifi commented Aug 4, 2022

I'm getting the same error:

Module cache already has entry .../got/dist/source/index.js. This is a bug in Jest, please report it!

I think it's related to dynamic imports:

const gotPromise = import('got')

Update: The error went away by moving the dynamic import away from the root of the file, and into the code that uses the import:

(await import('got')).got.get(...)

however now the whole test suite hangs forever

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Sep 3, 2022
@SimenB
Copy link
Member

SimenB commented Sep 3, 2022

@bameyrick sorry, missed this one! I get an error when trying to run npm run fetch

$ npm run fetch

> iso-3166-1-flags-sprite-generator@1.0.0 fetch
> ts-node src/fetch.ts

(node:11581) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/simen/repos/iso-3166-1-flags-sprite-generator/src/fetch.ts:1
import fetch from 'node-fetch';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1055:15)
    at Module._compile (node:internal/modules/cjs/loader:1090:27)
    at Module.m._compile (/Users/simen/repos/iso-3166-1-flags-sprite-generator/node_modules/ts-node/src/index.ts:1597:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/simen/repos/iso-3166-1-flags-sprite-generator/node_modules/ts-node/src/index.ts:1600:12)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at phase4 (/Users/simen/repos/iso-3166-1-flags-sprite-generator/node_modules/ts-node/src/bin.ts:579:12)

@github-actions github-actions bot removed the Stale label Sep 3, 2022
@SimenB
Copy link
Member

SimenB commented Sep 3, 2022

Never mind, seems like the step is not needed - I can reproduce 👍

@SimenB
Copy link
Member

SimenB commented Sep 3, 2022

https://github.com/facebook/jest/releases/tag/v29.0.2

@github-actions
Copy link

github-actions bot commented Oct 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2022
mifi added a commit to transloadit/uppy that referenced this issue Mar 13, 2023
fixes #4317

also upgrade jest to fix jestjs/jest#13008
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants