Skip to content

Restore Node 24 (and before) behavior as fs.existsSync() now throws deprecation warning#474

Open
kroh wants to merge 1 commit into
lando:mainfrom
kroh:fix-node24-deprecation-warning
Open

Restore Node 24 (and before) behavior as fs.existsSync() now throws deprecation warning#474
kroh wants to merge 1 commit into
lando:mainfrom
kroh:fix-node24-deprecation-warning

Conversation

@kroh

@kroh kroh commented Jul 17, 2026

Copy link
Copy Markdown

The problem

Execution of lando results in the following error:

$ lando setup
[DEP0187] DeprecationWarning: Passing invalid argument types to fs.existsSync is deprecated
  (Use `node --trace-deprecation ...` to show where the warning was created)

What was wrong

Node 24 introduced deprecation DEP0187: fs.existsSync() now warns when passed anything that isn't a string/Buffer/URL. Older Node silently returned false. Lando relies on that old behavior in many places — it calls fs.existsSync(x) where x is often undefined or an object (e.g. plugin dirs that don't exist, config source objects). Each command bootstraps different subsystems, so different call sites fired.

The fix

Rather than guard dozens of individual call sites (fragile and incomplete), I added a single global shim at Lando's entry point at @lando/core/bin/lando:

const _existsSync = fs.existsSync;
fs.existsSync = function(p) {
  if (typeof p !== 'string' && !Buffer.isBuffer(p) && !(p instanceof URL)) return false;
  return _existsSync.apply(this, arguments);
};

This restores the pre-Node-24 semantics (non-path argument returns false), so behavior is unchanged, just no warning.

@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

👷 Deploy request for lando-core pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 531c3c0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant