question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot resolve dependency 'async_hooks'

See original GitHub issue

🐛 bug report

Parcel doesn’t seem to know that async_hooks is a Node.js builtin when bundling with --target node.

parcel build src/index.js --target node --bundle-node-modules

🤔 Expected Behavior

A require('async_hooks') should be left as-is.

😯 Current Behavior

An error is thrown.

🚨  /app/node_modules/cls-hooked/context.js:7:28: Cannot resolve dependency 'async_hooks'
   5 | const assert = require('assert');
   6 | const wrapEmitter = require('emitter-listener');
>  7 | const async_hooks = require('async_hooks');
     |                            ^
   8 |
   9 | const CONTEXTS_SYMBOL = 'cls@contexts';
  10 | const ERROR_SYMBOL = 'error@context';

💁 Possible Solution

Add it to node-libs-browser?

💻 Code Sample

require('async_hooks');

🌍 Your Environment

Software Version(s)
Parcel 1.12.3
Node 12.1.0 alpine
npm/Yarn yarn@1.15.2
Operating System Linux 1e250ea9327f 4.9.125-linuxkit

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
gergancommented, Apr 23, 2020

Is there any possible workaround for the 1.x branch - I’m stuck with parcel 1.x, because it is a dependency of @aws-cdk/aws-lambda-nodejs ?

4reactions
mischniccommented, Nov 13, 2019

This is only fixed in Parcel 2, not in Parcel 1.x.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve 'async_hooks' - Stack Overflow
The problem with 'async_hooks' is that it will only be available in node on serverside - if e.g. webpack tries to create a...
Read more >
Module not found: Can't resolve 'async_hooks' error [Solved]
The command removes the single-build dependency from your project and copies the configuration files into your project as dependencies in package.json . shell....
Read more >
Nodejs APM - Can't resolve 'async_hooks' - Elastic Discuss
Hello, We are trying to use APM for our React nodejs app. We have added the dependency in our package.json to install the...
Read more >
open-telemetry/opentelemetry-node - Gitter
./node_modules/@opentelemetry/context-async-hooks/build/src/AsyncHooksContextManager.js Module not found: Can't resolve 'async_hooks' in 'D:\.
Read more >
@opentelemetry/context-async-hooks - npm
OpenTelemetry AsyncHooks-based Context Manager. Latest version: 1.8.0, last published: a month ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found