Skip to content

Module not found: Can't resolve '#async_hooks' #72

@alaindeurveilher

Description

@alaindeurveilher

Hi,

Since the update of v5.0.0 (updating from 4.0.0) I now get the following error:

⨯ ./node_modules/p-limit/index.js:2:0
Module not found: Can't resolve '#async_hooks'

My environment is NextJS 14, Node JS 20.8.0

I did not have the issue with pLimit v4.0.0

I see in the diff between 4.0.0 and 5.0.0 a new line for the usage of
import {AsyncResource} from '#async_hooks';

so the error is definitely coming from this update.

I also read a warning on the NodeJS webpage version 21.1 about the usage of async_hook: source: https://nodejs.org/api/async_hooks.html

Async hooks
Stability: 1 - Experimental. Please migrate away from this API, if you can. We do not recommend using the createHook, AsyncHook, and executionAsyncResource APIs as they have usability issues, safety risks, and performance implications. Async context tracking use cases are better served by the stable AsyncLocalStorage API. If you have a use case for createHook, AsyncHook, or executionAsyncResource beyond the context tracking need solved by AsyncLocalStorage or diagnostics data currently provided by Diagnostics Channel, please open an issue at https://github.com/nodejs/node/issues describing your use case so we can create a more purpose-focused API.

Is it safe to be used then? Is this API compatible with node 20 and below ?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions