Skip to content

registerHooks from node:module does not allow code snippets as hook argument #35151

@davidebombelli

Description

@davidebombelli

Version

deno 2.8.2 (stable, release, x86_64-unknown-linux-gnu)
v8 14.9.207.2-rusty
typescript 6.0.3

OS

Linux 6.8.0-111-generic x86_64 x86_64

Steps to reproduce

  1. create file test.js with the following code:
import { registerHooks } from 'node:module';

const hook1 = { printFunc(data) { console.log(data) } };

registerHooks(hook1);
  1. run it with deno test.js

Expected Behaviour

in Node.js, nothing is printed

Actual Behaviour

in Deno, an error is thrown:

error: Uncaught (in promise) TypeError: The argument 'hooks' must contain at least one of 'resolve' or 'load'. Received { printFunc: [Function: printFunc] }
registerHooks(hook1);
^
    at registerHooks (node:module:2473:11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions