Giter Club home page Giter Club logo

Comments (2)

jwoo0122 avatar jwoo0122 commented on September 26, 2024

From Node 20.12.0, ESM facade is build when it's necessary. Before this change (like, <=Node 20.11.1) when the fs module is imported, internal/fs/rimraf was also resolved.

In .pnp.cjs of yarn 3.8.1, we do require('fs'). At this point fs is not patched at all. So this happens:

  • If you're using Node.js <20.12.0, internal/fs/rimraf is resolved by getESMFacade. It uses non-pnp version of fs.readdirSync (original version), which can handle encoding option. No Error.
  • If you're using Node.js >=20.12.0, internal/fs/rimraf is not resolved. After we meet the code in user script which actually use internal/fs/rimraf (e.g fs.rmSync), node resolves the module. At this point we already done the preloading of pnp patching, so internal/fs/rimraf uses pnp-patched version of fs.readdirSync, which doesn't handle encoding option. But internal/fs/rimraf wants it to return the result as buffer array, so there's an Error.

from berry.

jwoo0122 avatar jwoo0122 commented on September 26, 2024

Looks like that yarn 4 NodeFS.readdir(Sync) supports the options correctly, but not for <3. So this error happens when you use Node.js 20.12.0 or later && yarn 3.x or earlier.

from berry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.