Issue Deploying Forge App: async_hooks Module Not Found

Hi Atlassian Developer Community,

I’m working on a Forge app called BOT-AI-PEOPLE-CHILE and have set up all the necessary files (manifest.yml, index.js, index.jsx). However, I keep hitting an error when trying to deploy the app with forge deploy:

Error: Bundling failed: Module not found: Error: Can’t resolve ‘async_hooks’ in ‘/Users/matiasmatthews/BOT-AI-PEOPLE-CHILE/node_modules/@forge/api/out/api’

Environment Details:

Forge CLI Version: 10.11.0
Node.js Version: I’ve tried both Node.js 18 and Node.js 20, but I get the same error with both.
Operating System: macOS Sequoia Version 15.1 (24B83)
Dependencies:

  • I’m using @forge/api and @forge/ui as recommended in the Forge docs.
  • I tried forcing an older version of @forge/api (2.6.0), but it didn’t help.

Troubleshooting Steps I’ve Already Tried:

  1. Reinstalled @forge/api with different versions (including 2.6.0).
  2. Deleted and reinstalled all dependencies (node_modules and package-lock.json).
  3. Updated Forge CLI to the latest version (10.11.0).
  4. Tested both Node.js 18 and 20 to make sure the Node version isn’t the issue.
  5. Tried manually adding async_hooks, but that didn’t fix it, so I assume it’s something internal to Forge.

Question:

Is there a known fix or workaround for this async_hooks error? It seems like it could be related to an internal dependency in @forge/api. Any guidance on how to handle this would be really appreciated, as it’s blocking me from moving forward with my app.

Thanks a lot for the help, and if there’s any temporary fix I could try, that’d be great to know!

Best,
Matías Matthews

3 Likes

I had the same error and it goes away if I use: “@forge/api”: “4.0.0”

Update your dependencies in your package.json and then run ‘npm i’:

“dependencies”: {
@forge/api”: “4.0.0”,
@forge/bridge”: “4.1.0”,
@forge/react”: “10.7.0”,
@forge/resolver”: “1.6.1”,
“react”: “^18.2.0”
}

I haven’t made it too far into validating that storage works, but the error goes away and you can deploy.

6 Likes

Thanks so much for this workaround. Was driving me crazy ever since upgrading @forge/cli to 10.11 yesterday.

I just ran into this error. I would interpret it as “double-check your frontend dependencies aren’t pulling in libs intended for the resolvers”.

For my case, I was bootstrapping a new app and adding Typescript:

├── manifest.yml
├── package-lock.json
├── package.json
├── src
│   ├── frontend
│   │   └── index.tsx
│   ├── index.ts
│   └── resolvers
│       ├── index.ts
└── tsconfig.json

I started writing a type and default object, which frontend would get from invoking the resolver. I put those into the ./resolvers/index.ts, then imported them into ./frontend/index.tsx. And that meant @forge/resolver was getting imported for the frontend code, which is what tripped the bundling error. The solution was to extract my “DTOs” to a separate file without imports. Both frontend and resolvers can share these now, without extraneous imports.

4 Likes

I’m still getting this error and have tried the solutions that Matt recommended as well as double checked for frontend dependencies pulling in libraries for resolvers.

This error occurs also for all tutorial and example apps that I’ve tried that use forge/api

2 Likes

I am also seeing this error when trying to use forge deploy.
image

I have tried changing the versions of all dependencies with no luck. Here is my package.json file

{
  "name": "confluence-context-menu-ui-kit-2",
  "version": "1.1.1",
  "main": "index.js",
  "license": "MIT",
  "private": true,
  "scripts": {
    "lint": "./node_modules/.bin/eslint src/**/*"
  },
  "devDependencies": {
    "eslint": "^8.56.0",
    "eslint-plugin-react-hooks": "^4.6.0"
  },
  "dependencies": {
    "@forge/api": "^4.1.2",
    "@forge/bridge": "4.2.0",
    "@forge/react": "10.10.0",
    "@forge/resolver": "1.6.3",
    "react": "^18.2.0"
  }
}

Here are my import statements.

import React, { useEffect, useState } from "react";
import ForgeReconciler, {
  Text,
  Form,
  FormSection,
  FormFooter,
  Textfield,
  TextArea,
  Label,
  Button,
  Select,
} from "@forge/react";
import api from "@forge/api";

I am currently running Forge CLI version 10.13.1. Any help would be greatly appreciated as this is preventing me from moving forward with the development of my application. Thank you.

"@forge/api": "^4.1.2",
"@forge/bridge": "4.2.0",
"@forge/react": "10.10.0",
"@forge/resolver": "1.6.3",

same with these versions

1 Like

Same issue here

I was having this issue, too, but the offending line was introduced in 4.1.0, so going back to 4.0.0 resolved the issue (like @matthew_smith suggested). If you’re still getting the error that @ZacharyKing attached, then you still have the wrong version for some reason. Try clearing out your node_modules dir as well add the package-lock file and re-run npm i

Thank you @ScottMartindale, not sure why I didn’t realize I hadn’t set the version back. But setting it to 4.0.0, removing node_modules and running npm i was all it took to get it this error removed.

1 Like

I am getting this error with the following configuration in node.js following a clear of node_modules and npm i

  "devDependencies": {
    "eslint": "^8.56.0",
    "eslint-plugin-react-hooks": "^4.6.0"
  },
  "dependencies": {
    "@atlaskit/adf-utils": "^19.16.0",
    "@forge/api": "^4.0.0",
    "@forge/bridge": "4.2.0",
    "@forge/react": "10.10.0",
    "@forge/resolver": "1.6.3",
    "react": "^18.2.0",
    "react-iframe": "^1.8.5"
  }

Any thoughts gratefully received

ok - resolved with "@forge/api": "4.0.0",

Try this idea, also.

I found that out of habit I imported the method from my resolver index.js file into the frontend’s index.jsx. I did this to assure that every method my React components used had a proper import for them.

However, backend resolver methods are not referenced by symbolic value but rather are referenced via their string names of their method through the bridge resolver.

So, I solved this issue reported in this ticket by removing the unnecessary and incorrect import for the actual method in the resolver/index.js file.

Hello everyone,

After investigating the issue, I can confirm that the root cause aligns with what @ibuchanan mentioned: importing backend packages (such as @forge/resolver, @forge/api, @forge/storage, @forge/events, etc.) within UI modules.

The error occurs because the frontend bundling process cannot resolve backend node modules like async_hooks.

To resolve this, please ensure that any direct or transitive dependencies on backend packages are removed from your UI code.

Hope that helps, thank you!

3 Likes

Not good enough. The Forge CLI should clearly tell the dev where the issue is and how to fix it.

There are other non-descript related errors to this:

Also fails if you have frontend Forge packages being imported at any point into the resolver, regardless of whether those packages are being used.

So my guess is the bundler is flawed.

2 Likes