Skip to content

ReferenceError: File is not defined on pre-commit hook #495

@LokeshShelva

Description

@LokeshShelva

Have you checked that the bug is not already fixed?

Yes

Summary

The following error occurs when markdown-link-check is run as part of pre-commit hook

/home/vscode/.cache/pre-commit/repoeb1dlzvo/node_env-system/lib/node_modules/markdown-link-check/node_modules/undici/lib/web/webidl/index.js:512
webidl.is.File = webidl.util.MakeTypeAssertion(File)
                                               ^

ReferenceError: File is not defined
    at Object.<anonymous> (/home/vscode/.cache/pre-commit/repoeb1dlzvo/node_env-system/lib/node_modules/markdown-link-check/node_modules/undici/lib/web/webidl/index.js:512:48)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/home/vscode/.cache/pre-commit/repoeb1dlzvo/node_env-system/lib/node_modules/markdown-link-check/node_modules/undici/lib/web/fetch/util.js:12:20)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)

Node.js v18.19.0

This is how the pre-commit is setup

repos:
  - repo: https://github.com/tcort/markdown-link-check
    rev: v3.13.7
    hooks:
      - id: markdown-link-check
        args: [--config, .markdown-link-check.jsonc, --quiet]

Affected version

3.13.7

Steps to reproduce the bug

  • Add following to pre-config

    repos:
      - repo: https://github.com/tcort/markdown-link-check
        rev: v3.13.7
        hooks:
          - id: markdown-link-check
            args: [--config, .markdown-link-check.jsonc, --quiet]
  • Run the pre-commit hook

Expected behavior

The pre-commit should complete without any error

Actual behavior

The following error is occuring

/home/vscode/.cache/pre-commit/repoeb1dlzvo/node_env-system/lib/node_modules/markdown-link-check/node_modules/undici/lib/web/webidl/index.js:512
webidl.is.File = webidl.util.MakeTypeAssertion(File)
                                               ^

ReferenceError: File is not defined
    at Object.<anonymous> (/home/vscode/.cache/pre-commit/repoeb1dlzvo/node_env-system/lib/node_modules/markdown-link-check/node_modules/undici/lib/web/webidl/index.js:512:48)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/home/vscode/.cache/pre-commit/repoeb1dlzvo/node_env-system/lib/node_modules/markdown-link-check/node_modules/undici/lib/web/fetch/util.js:12:20)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)

Node.js v18.19.0

Additional context

No response

Can you fix it?

Maybe

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalebugissue is a bug or pull request fixes a bugtriage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions