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

ReferenceError: EISDIR is not defined | node pollyfill is missing a constant #23695

Closed
bowtiedgnome opened this issue May 4, 2024 · 1 comment · Fixed by #23829
Closed

ReferenceError: EISDIR is not defined | node pollyfill is missing a constant #23695

bowtiedgnome opened this issue May 4, 2024 · 1 comment · Fixed by #23829
Labels
bug Something isn't working node compat

Comments

@bowtiedgnome
Copy link

Version: Deno 1.42.4

The following code is resulting in an error

      if (isDirectory && !options.recursive) {
        throw new ERR_FS_EISDIR({
          code: "EISDIR",
          message: "is a directory",
          path,
          syscall: "rm",
          errno: EISDIR,
        });
      }

see: https://github.com/denoland/deno/blob/main/ext/node/polyfills/internal/fs/utils.mjs

Most likely the linked code needs to be updated to:

      if (isDirectory && !options.recursive) {
        throw new ERR_FS_EISDIR({
          code: "EISDIR",
          message: "is a directory",
          path,
          syscall: "rm",
          errno: osConstants.errno.EISDIR,
        });
      }

The error that I see.

error: ReferenceError: EISDIR is not defined
    return fs.rmSync(path,  { ...options });
              ^
    at __node_internal_ (ext:deno_node/internal/fs/utils.mjs:894:18)
    at Object.rmSync (ext:deno_node/_fs/_fs_rm.ts:27:13)
    at removeSync (file:///{redacted}/gnomejs/fs/node/mod.ts:494:15)
    at file:///{redacted}/gnomejs/fs/move_node_test.ts:246:3

(I can work around it by setting options.force, however, this seems like a bug).

@marvinhagemeister
Copy link
Contributor

For completeness: These are the steps to reproduce the error.

  1. Create a file main.ts with these contents:
import fs from "node:fs";
import * as path from "node:path";

const dir = path.join(import.meta.dirname!, "foo");
fs.rmSync(dir);
  1. Create an empty folder foo next to main.ts
  2. Run deno run -A main.ts

@marvinhagemeister marvinhagemeister added bug Something isn't working node compat labels May 8, 2024
marvinhagemeister added a commit that referenced this issue May 16, 2024
The `EISDIR` error code is not available as a global variable, but must
be accessed through the `osConstants.errno` object.

Fixes #23695
bartlomieju pushed a commit that referenced this issue May 16, 2024
The `EISDIR` error code is not available as a global variable, but must
be accessed through the `osConstants.errno` object.

Fixes #23695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants