"Error: Bindings not found" when installing the Node agent

  • Updated

Issue

When installing the Contrast Security Node Agent, you may encounter the following error:

{"level":10,"time":1693600552019,"pid":23961,"hostname":"b8cd455bb5e8","name":"contrast","name":"contrast:patcher","msg":"adding hooks: function-hooks:Function.prototype.toString"} 
Waiting for the debugger to disconnect... 
/node_modules/@swc/core/index.js:250 
  throw new Error("Bindings not found"); 
^ Error: Bindings not found at Compiler.transformSync (/node_modules/@swc/core/index.js:250:15) at transformSync (/node_modules/@swc/core/index.js:348:21) at Object.rewrite (/node_modules/@contrast/rewriter/lib/index.js:67:20) at Module._compile (/node_modules/@contrast/agentify/lib/rewrite-hooks.js:30:40) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.__loadOverride [as _load] (/node_modules/@contrast/require-hook/lib/require-hook.js:71:35) at Function.executeUserEntryPoint (node:internal/modules/run_main:81:12) at Agent.Module.runMain (/node_modules/@contrast/agentify/lib/index.js:110:27) Node.js v18.16.1 Waiting for the debugger to disconnect...

Cause

The error arises because Node.js is looking for a compiled binary that matches your platform. SWC (the rewriter Contrast Node Agent uses) is designed to execute this binary to perform code transformation. The agent installation process involves installing SWC along with its optional dependencies, which are platform-specific. If SWC fails to correctly install the necessary platform-specific bindings, it can result in the Bindings not found error.

Resolution

There are two ways we could resolve this:

Method 1 - Reinstall the Contrast Node Agent (preferred method):
The simplest solution is to reinstall the agent on the same machine where your application is running. This ensures that the correct platform-specific bindings are installed.
Run the following to install the Contrast Node Agent:

npm install @contrast/agent

 

Method 2 - Manually Reinstall SWC:
This method is a little more involved as we'll need to find the version of @swc/core our agent requests. To do this:

  1. Navigate to node_modules/@contrast/rewriter/package.json and look for the required version of @swc/core.
  2. Install the version of SWC that the agent requires:
    npm install @swc/core@<version_found_in_step_1>

 

 

 

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request