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

Memfs throwing an error after update to version 3 #7266

Closed
6 tasks done
pjotrsavitski opened this issue Jan 16, 2025 · 6 comments · Fixed by #7271
Closed
6 tasks done

Memfs throwing an error after update to version 3 #7266

pjotrsavitski opened this issue Jan 16, 2025 · 6 comments · Fixed by #7271

Comments

@pjotrsavitski
Copy link
Contributor

Describe the bug

Mocking filesystem with memfs as described here throws an error with version 3.

This is what I got using the example code:

Instead change the require of ...../node_modules/tslib/tslib.es6.mjs to a dynamic import() which is available in all CommonJS modules.
Error [ERR_REQUIRE_ESM]: require() of ES Module ...../node_modules/tslib/tslib.es6.mjs not supported.
Instead change the require of ...../node_modules/tslib/tslib.es6.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (...../node_modules/tree-dump/lib/index.js:3:17)

Reproduction

Vitest 3 with code from example

System Info

System:
    OS: macOS 15.2
    CPU: (12) arm64 Apple M2 Max
    Memory: 1.36 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - /usr/local/bin/node
    npm: 10.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 131.0.6778.265
    Edge: 131.0.2903.147
    Safari: 18.2
  npmPackages:
    @vitejs/plugin-react: ^4.3.2 => 4.3.4 
    @vitest/coverage-v8: ^3.0.0 => 3.0.0 
    vite: ^6.0.7 => 6.0.7 
    vitest: ^3.0.0 => 3.0.0

Used Package Manager

npm

Validations

@boldurean
Copy link

Same happens when using Mui with @emotion styles

@vladkrasn
Copy link

vladkrasn commented Jan 16, 2025

I had similar errors with some other package on Node v22.6 and after updating to v22.13 they disappeared

@sandhose
Copy link

I'm also experiencing this, with Vitest 3, but only with Vite 6. Downgrading Vite to 5 (but keeping Vitest at version 3) 'fixes' it, so I suspect it is because of something which changed in Vite 6

@tsirlucas
Copy link
Contributor

tsirlucas commented Jan 16, 2025

Same happens when using Mui with @emotion styles

same issue. fixed by updating node to 22.13.

It works fine on 3.0.0-beta.4.

@Primajin
Copy link

I can confirm updating node from 21 to 22 the error disappeared. However this feels a bit like slapping flex tape on a leaking water tank to me 🤔

Primajin/satellite-tracker@7927a2f

@pjotrsavitski
Copy link
Contributor Author

pjotrsavitski commented Jan 16, 2025

As @sandhose mentioned the problem arises with Vitest version 3 and Vite version 6. For some reason downgrading to previous version make the issue disappear. It seems strange as the tree-dump is still there as a dependency of the memfs.

Forgot to mention that there is another issue with the example code as readHelloWorld would return a buffer and test would compare that buffer with texts. The function body would either need to be changed to readFileSync(path, { encoding: 'utf8', flag: 'r' }) to return string or the test would need to be modified to call .toString() each time the buffer value is compared to a text. The first solution seems to be more reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants