AppDynamics Native Agent Not Loading with Nexe-bundled NodeJS Application
Environment
- Node.js version: 20.9.0
- AppDynamics Node.js Agent version: Latest
- Nexe version: Latest
- OS: Windows Server
- Build tool: Nexe with custom build script
Project Structure
We have a Node.js API service that uses:
- Express.js for REST API
- Native modules (specifically AppDynamics agent)
- Various npm packages for business logic
- Built and distributed as a single executable using Nexe
Issue
When running our Nexe-bundled application, the AppDynamics agent fails to initialize with the following error:
Appdynamics agent cannot be initialized due to Error: Missing required module. \\?\C:\Path\nodejs_api\node_modules\appdynamics-libagent-napi\appd_libagent.node TypeError: Cannot read properties of undefined (reading 'init') at LibagentConnector.init
What We've Tried
1. Including the native module as a resource in Nexe build:
--resource "./node_modules/appdynamics-libagent-napi/appd_libagent.node"
2. Copying the native module to the correct directory structure in distribution:
dist/
- api_node.exe
- node_modules/
-- appdynamics-libagent-napi/
--- appd_libagent.node
According to Nexe's documentation, when dealing with native modules (.node files), the module should be placed in the `node_modules` directory relative to the compiled executable's location. This means that while the application is bundled into a single executable, native modules are expected to be loaded from the filesystem at runtime.
Question
How can we properly bundle and load the AppDynamics native agent with a Nexe-compiled Node.js application? Is there a specific configuration or approach needed for native modules, particularly AppDynamics, to work with Nexe?
Any guidance or working examples would be greatly appreciated.
Hello @extalt,
Thank you for asking your question on the Community. I'm not a product expert. Let's see if the community can jump in and help.
If you don't get a reply soon, you can each out to AppDynamics Support. https://community.splunk.com/t5/AppDynamics-Knowledge-Base/How-do-I-open-a-case-with-AppDynamics-Sup...
@iamryan can you look that sir please.