Bot hosted in Azure with Google Vision Api - gRPC issue - node.js

Trying to use Google Vision Api from Bot Framework app hosted on Azure. The code works just fine on local but I get this error when I try it on Azure. Can someone help?
Exception while executing function: Functions.messages. mscorlib: Error: A dynamic link library (DLL) initialization routine failed.
\\?\D:\home\site\wwwroot\messages\node_modules\grpc\src\node\extension_binary\grpc_node.node
at Error (native)
at Object.Module._extensions..node (module.js:583:18)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\home\site\wwwroot\messages\node_modules\grpc\src\node\src\grpc_extension.js:38:15)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10).
Here is the package.json that I am using:
{
"name": "luisbot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"#google-cloud/vision": "^0.10.0",
"botbuilder": "^3.7.0",
"botbuilder-azure": "3.0.2",
"botbuilder-location": "^1.0.4"
},
"devDependencies": {
"restify": "^4.3.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
and the error throws while loading the vision api module - at the line mention below
var vision = require('#google-cloud/vision')

As of now, using grpc modules from inside the function code is not supported as Functions runtime uses Edge.js for executing JavaScript code and it does not have support for loading native modules. Related issue.

Related

Error : Cannot find Module 'fabric-client' in fabric 1.2

Even after trying "npm update" command, still i am facing fabric-client error. The error details given below
Fabric version - 1.2 |
OS - Amazon Linux2 |
command - npm i
[root#ip-172-31-61-27 controller]# node app.js
module.js:538
throw err;
^
Error: Cannot find module 'fabric-client'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/ec2-user/AWSNodeApp/controller/app.js:27:11)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Below is the content of package.json
{
"name": "awsnodeapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.538.0",
"body-parser": "^1.17.1",
"cors": "^2.8.3",
"express": "^4.15.2",
"express-session": "^1.15.2",
"fabric-ca-client": "1.3.0",
"fabric-client": "1.3.0",
"fs-extra": "^2.0.0",
"log4js": "^3.0.6",
"uuid": "^3.3.2",
"ws": "^6.1.0"
}
}
That looks like the kind of error you get if you haven't actually downloaded your project dependencies with npm install prior to running your application. Or have not included a dependency required by your code in your project's package.json. Or possibly the npm install failed to download the dependencies due to connectivity issues accessing the npm registry. Either way, if you don't have a node_modules/fabric-client directory within your project directory, you haven't downloaded your required dependency.
The fabric-client#1.2 package definitely exists: https://www.npmjs.com/package/fabric-client/v/1.2.2
Note that this version of Hyperledger Fabric is obsolete. As of today (August 2020), you really should be using v1.4 or (ideally) v2.2. Note that the Node SDK has changed with the v2.2 release and, although the v1.4 fabric-client package will still work with a v2.2 Fabric, it is recommended to use fabric-network#2.2: https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-migration.html
fabric client module is not installed in your project. try this command to install fabric-client module
npm i fabric-client

Cannot find module './mergeConfig' when running on Heroku

I have a node application that runs fine when executed on my machine via node my_application.js.
However, if push it to heroku and execute it via heroku run node my_application.js or with the scheduler what I get is this error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module './mergeConfig'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/node_modules/axios/lib/core/Axios.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
I'm running node v10.16.0 and npm v6.9.0 both locally and on Heroku, so I really don't know what may be causing this issue, and googling for it didn't help in any way.
Any ideas about this mergeConfig module that seems to be missing from my heroku environment but not from my local environment?
Edit: this is my package.json:
{
"name": "[REDACTED]",
"version": "1.0.0",
"description": "[REDACTED]",
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"bluebird": "^3.5.3",
"body-parser": "^1.18.3",
"dateformat": "^3.0.3",
"express": "^4.16.4",
"form-data": "^2.3.3",
"http-to-curl": "^1.4.2",
"jest": "^24.8.0",
"qs": "^6.6.0",
"querystring": "^0.2.0",
"redis": "^2.8.0",
"simple-oauth2": "^2.2.1"
}
}
Try to add explicitly the missing module in the dependencies in package.json:
"dependencies": {
...
"merge-config" :"2.0.0"
...
}
I think it works on your local environment because you have the module installed globally.
I had the same problem.
'./mergeConfig' is a file inside de axios module.
Path: node_modules/axios/core/mergeConfig.js
For some reason heroku had a problem with this file.
I solved it by replacing axios with request.
This fixed the problem for me NODE_OPTIONS=--max_old_space_size=4096
src: https://github.com/axios/axios/issues/1767#issuecomment-416924946

Visual Studio Code unable to debug Electron

I am using Electron on Visual Studio Code on Windows 8. I am new to Electron.
I used the electron-quick-start which works in Visual Studio Code when running it with the VS Code terminal. But when I try to debug the code I get the following error:
Debugger listening on [::]:46522
e:\Projects\BT\electron-quick-start\main.js:40
app.on('ready', createWindow)
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (e:\Projects\BT\electron-quick-start\main.js:40:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
The error occurs when the debugger reaches the following line in main.js:
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
I exactly use the code in electron-quick-start. That means for package.json:
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "~1.6.2"
}
}
What have I to do to can debug this code in Visual Studio Code
It showed that this was a global problem that was fixed in the new update 1.17.2 of VS Code. So I don't know why some people have downgraded this question although it was a relevant question and why stackoverflow allows that, but for all the people who have had this problem, I post this answer.
After installing the new update 1.17.2 the problem was fixed. VS Code has solved that in version 1.17. Here are some info about the features and bug fixes (including the electron feature in VS Code).

error deploying node.js app to heroku

I'm trying to deploy my node.js app to heroku.
I'm getting this error on git push heroku master:
> on-headers#1.0.1 test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/response-time/node_modules/on-headers
> mocha --reporter spec --bail --check-leaks test/
/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) 'test/'
at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15)
at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30
at Array.forEach (native)
at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
> node-statsd#0.1.1 test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/soluto-monitor/node_modules/node-statsd
> mocha -R spec
/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) 'test'
at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15)
at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30
at Array.forEach (native)
at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
...
..and on and on with the error Error: cannot resolve path (or pattern) 'test/' for each node_modules subdirectory.
my package.json looks like more or less like this:
{
"name": "my-module",
"version": "0.1.0",
"description": "My Module",
"dependencies": {
"azure-storage": "0.6.0",
"bluebird": "3.0.6",
"body-parser": "1.14.1",
"cors": "2.7.1",
"dotenv": "^1.2.0",
"express": "3.3.3",
"moment": "2.10.6",
"request-promise": "1.0.2",
"rx": "4.0.7",
"shisell": "0.0.2",
"striptags": "2.0.4",
"winston": "2.1.1"
},
"devDependencies": {
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"mocha": "^2.3.4",
"mock-require": "^1.2.1",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"supertest": "^1.1.0"
},
"main": "server.js",
"engines": {
"node": "4.2.3"
},
"scripts": {
"test": "mocha"
}
}
it seems like mocha is trying to run from within node_modules, inside each dependency. i managed to reproduce the error locally by running mocha from within one of the node_modules directories.
I tried removing test script from my package.json and I still get the same error.
I'm new to heroku deployments. As far as I understood once I git push to heroku then heroku runs npm install and if there is a test script it will run. But I don't understand what causes it to try and run mocha within subdirectories of node_modules (and why that would happen even if I don't specify a test script inside my package.json).
Any ideas?
p.s. this doesn't happen when I run locally on my machine.
Turns out I had this environment variable set: NPM_CONFIG_NPAT=true on heroku and it causes npm to run tests on all the installations, as described here:
https://docs.npmjs.com/misc/config#npat

ORMError NO_SUPPORT: Connection protocol not supported - have you installed the database driver for postgres?

I'm trying to deploy a nodejs application on ubuntu 13.10. I have tested it on my local mac( working good).
But when I try to run it on my ubuntu server, i got this:
[ORMError NO_SUPPORT: Connection protocol not supported - have you installed the database driver for postgres?]
at Object.exports.connect (/home/ubuntu/node_modules/orm/lib/ORM.js:138:21)
at Object.module.exports (/home/ubuntu/node_modules/orm/lib/Express.js:12:6)
at Object.exports.express (/home/ubuntu/node_modules/orm/lib/ORM.js:39:30)
at Object.<anonymous> (/home/ubuntu/www/sher/nodejs/app.js:30:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
error: Forever detected script exited with code: 8
FYI:
I installed npm install pg after i got this error, but didn't work.
I also instadded postgresql9.1 with sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libxml2-dev libproj-dev libjson0-dev xsltproc docbook-xsl docbook-mathml.
Anyone can suggest any idea whats going on here?
Thank you!
{
"name": "nodejs",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.2.0",
"static-favicon": "~1.0.0",
"morgan": "~1.0.0",
"cookie-parser": "~1.0.1",
"body-parser": "~1.0.0",
"debug": "~0.7.4",
"jade": "~1.3.0"
}
}
I just reinstalled all packages and modules again one by one. Seems fixed the problem.

Resources