Error "The specified module could not be found" on hyperledger Aries - node.js

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!

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 !

Related

Why am I getting module not found when I have double and triple checked that it is there?

So I'm trying to search google programmatically, and to do so i'm using the node module google-search-results-nodejs, but despite anything I do I keep getting the error not found. I'm working on gitpod online workspace. I wasn't sure if perhaps this had something to do with it but for the life of me I just can't figure it out, and I've looked elsewhere and can't find anything. I tried to check if perhaps my files were in the wrong location, tried uninstalling all node-modules folder and reinstalling it.
Any ideas
const SearchAPI = require('google-search-results-nodejs');
const search = new SearchAPI.GoogleSearchResults(
"663185d5-API-KEY-76787e11787a9"
);
const params = {
engine: 'google_reverse_image',
image_url: 'https://i.imgur.com/E4cOSLw.jpg',
};
const cb = function (data) {
console.log(data['inline-images']);
};
// here
search.json(params, cb);
Here's the error response:
gitpod /workspace/Copyright-Content-Removal/node_modules $ node app.js
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '/workspace/Copyright-Content-Removal/node_modules/app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
EDIT: Just retested it and am getting this https://ibb.co/YPBX5Y1 error message.... Also I attached a video link below
Your app.js is inside node_modules directory -
/workspace/Copyright-Content-Removal/node_modules/app.js
But actually your app.js should be outside the node_modules directory like this -
/workspace/Copyright-Content-Removal/app.js

googleapis-common throwing error in UUID dependency

I'm trying to get a very basic oauth example to work in a node.js app with express and googleapis. Upon running the application it throws a TypeError inside the UUID dependency which is included with the googleapis-common module. I'm getting a bit frustrated at this point because I have not been able to find any additional information about this to allow me to resolve it myself.
Take a look at the screenshot below for the specifics:
Here it is in text if that makes things easier:
Exception has occurred: TypeError: Cannot assign to read only property 'name' of function 'function generateUUID(value, namespace, buf, offset) {
if (typeof value === 'string') {
value = strin...<omitted>... }'
at _default (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\v35.js:71:23)
at Object.<anonymous> (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\v3.js:14:27)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\index.js:63:34)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
The file this is being thrown in is called "v35.js".
My initial thought is that I must be missing some additional library that interprets the logic throwing the error differently. Eager to learn more about this and find a resolution.
Looks like this is how the uuid module works
node_modules/uuid/dist/v35.js
function _default(name, version, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
...
} // Function#name is not settable on some platforms (#270)
try {
generateUUID.name = name; // eslint-disable-next-line no-empty
} catch (err) {} // For CommonJS default export support
...
Authors warn (comment on line 4), that name property may not be settable and bypass it with empty catch

Error while trying to serialize a Qlik Sense app into a JSON object

I am trying to serialize a Qlik Sense app (.qvf file) into a JSON object.
For that I am passing the .qvf file in the below code as directed here - https://github.com/mindspank/serializeapp
The main reason behind this exercise is to save the JSON in Gitlab for version control since we cannot save .qvf in Git for version control as it is a binary file.
var qsocks = require('qsocks')
var serializeapp = require('serializeapp')
qsocks.Connect()
.then(global => global.openDoc('Executive D:\Users\ddas7071\Documents\Qlik\Sense\Apps\NewDeb.qvf'))
.then(app => serializeapp(app))
.then(result => console.log(result))
serializeapp = require('serializeapp')
const enigma = require('enigma.js')
const WebSocket = require('ws')
enigma.getService('qix', {
schema: require(`./node_modules/enigma.js/schemas/qix/12.67.2.json`),
session: {
host: 'localhost',
port: 4848,
secure: false
},
createSocket: (url) => new WebSocket(url)
})
.then(qix => qix.global.openDoc('Executive
D:\Users\ddas7071\Documents\Qlik\Sense\Apps\NewDeb.qvf'))
.then(app => serializeapp(app))
.then(result => console.log(result))
But while running the code (in windows), I am running into the below problem -
D:\Users\ddas7071\Desktop\Novartis_TechnicalDetails\myfile.js:12
enigma.getAttribute('qix', {
^
TypeError: enigma.getAttribute is not a function
at Object. (D:\Users\ddas7071\Desktop\Novartis_TechnicalDetails\myfile.js:12:8)
[90m at Module._compile (internal/modules/cjs/loader.js:1158:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:1002:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)[39m
[90m at internal/main/run_main_module.js:18:47[39m
Though I understand the error, but not sure how to resolve it.
Note - All the pre-requisites are being taken care of already.
qsocks is not supported from some time and serializeapp is using qsocks under the hood.
If you want to connect to Qlik Engine please the official package - enigma.js. But there is no JS package (as far as i know that can extract the objects information.
But ...
There is a CLI (official) that can do this for you (havent tested it myself) - corectl. Corectl have option to unbuild the app into separate json/yaml files which you can then put under version control
The description for the unbuild command
Extracts generic objects, dimensions, measures, variables, reload script and connections from an app in an engine into separate json and yaml files. In addition to the resources from the app a corectl.yml configuration file is generated that binds them all together. Passwords in the connection definitions can not be exported from the app and hence need to be handled manually. Generic Object trees (e.g. Qlik Sense sheets) are exported as a full property tree which means that child objects are found inside the parent´s json (the qChildren array).

Error while importing one file into another in Node.JS

I am using import while importing some functions from my practice.js file into different.js file.
practice.js file:-
function sum(x,y){
return x+y;
}
const pi = 3.14;
module.exports = {
sum : sum,
pi:pi
};
different.js file:-
import {sum,pi} from "./practice.js";
console.log("2 pie: "+sum(pi,pi));
Now when I am using require, the output is proper and no error is given.
When I am using import, there is this following error:-
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:749:23)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
at Function.Module._load (internal/modules/cjs/loader.js:604:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:868:12)
at internal/main/run_main_module.js:21:11
I have asked my colleagues and they told me that this is about ES6 and Babel is not configured in your system.
But I am not sure how to proceed with this. Can anybody please help me how to do it?
Rename your main file (different.js) to different.mjs.
Rename your practice.js file to practice.mjs and make it look like this:
function sum(x, y) {
return x + y;
}
const pi = 3.14;
export {sum, pi};
Then run node --experimental-modules different.mjs to run Node with it's experimental module loader.
You can read more here

NodeJS: How to fix "cannot find module 'node-windows' while compiling with pkg

While working on a particular project, I discovered I could compile my console applications with the pkg module. After installing it, I tested it out on my main app and it worked. When I tried it on "Service.js" (a service installer in the project) I got the warning (despite the fact that I have node-windows in the node_modules folder)
Warning Cannot find module 'node-windows' from 'C:\Users\Uchenna\Documents\NodeJS\Ghost'
C:\Users\Uchenna\Documents\NodeJS\Ghost\Service.js
I tried ignoring it and went ahead to run "Service.exe --install"then I got this error:
Error: Cannot find module 'node-windows'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:592:15)
at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1280:46)
at Function.Module._load (internal/modules/cjs/loader.js:518:25)
at Module.require (internal/modules/cjs/loader.js:648:17)
at Module.require (pkg/prelude/bootstrap.js:1159:31)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\snapshot\Ghost\Service.js:0:0)
at Module._compile (pkg/prelude/bootstrap.js:1254:22)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:711:10)
at Module.load (internal/modules/cjs/loader.js:610:32)
Here's the code in the Service.js file
const Service = require("node-windows").Service;
class ServiceInstaller
{
constructor () {
var logServerService = new Service({
name: "Log Server Service",
description: "Listens for data to log",
script: "./DataLoggerServer.exe"
});
var mainService = new Service({
name: "Main Application Service",
description: "Logs data (or errors) to the Log Server Service",
script: "./Ghost.exe"
});
}
installServices () {
logServerService.install();
mainService.install();
logServerService.on("install", function () {
logServerService.start();
console.log("Successfully installed the 'Log Server' service\n");
});
mainService.on("install", function () {
mainService.start();
console.log("Successfully installed the main service\n");
});
}
uninstallServices () {
logServerService.uninstall();
mainService.uninstall();
logServerService.on("install", function () {
logServerService.start();
console.log("Successfully uninstalled the 'Log Server' service\n");
});
mainService.on("install", function () {
mainService.start();
console.log("Successfully uninstalled the main service\n");
});
}
}
var installer = new ServiceInstaller();
if (process.argv[2] == "install") {
installer.installServices();
}
else if (process.argv[2] == "uninstall") {
installer.uninstallServices();
}
else {
console.log("Not running...\n");
}
Certain packages when build using pkg is showing this error.
For me it was bcrypt.
Look into the error message and find out which executable the error message is referring to. Then copy that executable from node_modules folder (mostly it will be from this folder), and paste it along side the executable.
This resolved the issue for me

Resources