vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
12.61k stars 1.13k forks source link

Unable to resolve correctly for `node_moduels` soft links on Windows #4841

Open JounQin opened 8 months ago

JounQin commented 8 months ago

Describe the bug

→ Failed to load plugin 'mdx' declared in 'BaseConfig': Cannot find module 'D:\a\eslint-mdx\eslint-mdx\node_modules\eslint-plugin-mdx\lib\index.js'. Please verify that the package.json has a valid "main" entry

Reproduction

https://github.com/mdx-js/eslint-mdx/actions/runs/7378053284/job/20072722711?pr=508

https://github.com/mdx-js/eslint-mdx/tree/build/yarn_v4

System Info

Windows on CI

local:

  System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 12.77 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/Library/Caches/fnm_multishells/89034_1703864877615/bin/node
    Yarn: 4.0.2 - ~/Library/Caches/fnm_multishells/89034_1703864877615/bin/yarn
    npm: 10.2.3 - ~/Library/Caches/fnm_multishells/89034_1703864877615/bin/npm
    bun: 1.0.20 - /opt/homebrew/bin/bun
  Browsers:
    Brave Browser: 120.1.61.109
    Chrome: 120.0.6099.129
    Safari: 17.2.1
  npmPackages:
    @vitest/coverage-istanbul: ^1.1.1 => 1.1.1 
    vitest: ^1.1.1 => 1.1.1

Used Package Manager

yarn

Validations

sheremet-va commented 8 months ago

I don't understand what is the problem here. From what I can see the error happens in @eslint/eslintrc/lib/shared/relative-module-resolver.js, why is this a Vitest error?

sheremet-va commented 8 months ago

From what I can see it uses require:

https://github.com/coderaiser/eslintrc/blob/99adbac4fec25a50e466946833677351eb8794b9/lib/shared/relative-module-resolver.js#L23

Vitest never supported and will never support intercepting require.

JounQin commented 8 months ago

Well, the error only occurs on Windows.

JounQin commented 8 months ago

why is this a Vitest error?

I'm migrating from jest, there is no such issue when using jest.