Search code examples
node.jstypescriptnode-moduleshyperledger

Error "The specified module could not be found" on hyperledger Aries


after doing everything from https://aries.js.org/guides/getting-started/set-up , i'm trying to copy paste this code to initialize the agent

//imports for indy-sdk
import type { InitConfig } from '@aries-framework/core'
import { Agent } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/node'
import { HttpOutboundTransport, WsOutboundTransport } from '@aries-framework/core'
import { HttpInboundTransport } from '@aries-framework/node'
// The agent initialization configuration

const config: InitConfig = {
    label: 'docs-nodejs-agent',
    walletConfig: {
        id: 'wallet-id',
        key: 'testkey0000000000000000000000000',
    },
}
// Creating an agent instance
const agent = new Agent(config, agentDependencies)
// Registering the required in- and outbound transports

agent.registerOutboundTransport(new HttpOutboundTransport())
agent.registerInboundTransport(new HttpInboundTransport({ port: 3000 }))
// Function to initialize the agent
const initialize = async () => await agent.initialize().catch(console.error)

but on visual studio 2022, it gives me this error:

C:\Users\Tosat\Desktop\Ladon\LadonHyperledgerAries\node_modules\bindings\bindings.js:121
        throw e;
        ^

Error: The specified module could not be found.
\\?\C:\Users\Tosat\Desktop\Ladon\LadonHyperledgerAries\node_modules\indy-sdk\build\Release\indynodejs.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1243:18)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at bindings (C:\Users\Tosat\Desktop\Ladon\LadonHyperledgerAries\node_modules\bindings\bindings.js:112:48)
    at Object.<anonymous> (C:\Users\Tosat\Desktop\Ladon\LadonHyperledgerAries\node_modules\indy-sdk\src\indyBinding.js:1:37)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v19.0.1

the problem is that the file at C:\Users\Tosat\Desktop\Ladon\LadonHyperledgerAries\node_modules\indy-sdk\build\Release\indynodejs.node exists and is right.... Thanks in advance!


Solution

  • I had the same problem and i think i found the solution at least for windows so i hope you're also on windows otherwise i don't think this will help you a lot.

    First step is: downloading the the prebuilt libraries of the indy-sdk at https://repo.sovrin.org/windows/libindy/master/1.16.0-1636/libindy_1.16.0.zip as stated in https://aries.js.org/guides/getting-started/installation/nodejs/windows

    Second step is: unpacking these somewhere in a folder

    Third step is: Setting these libraries in your Environment variables > System Variables as stated in the docs linked above as LD_LIBRARY_PATH and make sure the value points to the /lib folder of where you unpacked the prebuilt libraries

    I did these steps above and still had the issue you had and somewhere i found a mention that the indy-sdk requires the libindy in your system PATH https://www.npmjs.com/package/indy-sdk. So i did exactly that as well.

    So the fourth step is: Select Path under your System variables and click Edit. Then click new and paste the location of your extracted /lib so the same value that the LD_LIBRARY_PATH has.

    Fifth Step is not forgetting to restart and retreading the installing of dependencies with yarn add ... as stated in the setup https://aries.js.org/guides/getting-started/set-up. This can be crucial since it took a restart for it to work after doing all of this

    Let me know if this worked for you !