Skip to content

Memfs throwing an error after update to version 3Β #7266

Closed

Description

@pjotrsavitski

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

Activity

  1. boldurean commented on Jan 16, 2025

    @boldurean

    Same happens when using Mui with @emotion styles

  2. vladkrasn commented on Jan 16, 2025

    @vladkrasn

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

  3. sandhose commented on Jan 16, 2025

    @sandhose

    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

  4. tsirlucas commented on Jan 16, 2025

    @tsirlucas
    Contributor

    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.

  5. Primajin commented on Jan 16, 2025

    @Primajin

    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

  6. pjotrsavitski commented on Jan 16, 2025

    @pjotrsavitski
    ContributorAuthor

    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.

  7. locked and limited conversation to collaborators on Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions