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).
Related
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
Question:
I am trying to use couchbase in an electron application, but fail to run the electron application as soon as I include the couchbase module. How can I use couchbase with electron?
Error message:
C:\dev\app>npm start
> eej#1.0.0 start C:\dev\app
> electron .
App threw an error during load
Error: The module '\\?\C:\dev\app\node_modules\couchbase\build\Release\couchbase_impl.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 76. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func (electron/js2c/asar.js:140:31)
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1016:18)
at Object.func (electron/js2c/asar.js:140:31)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:816:32)
at Module._load (internal/modules/cjs/loader.js:728:14)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
My main.js file begins like this:
const { app, BrowserWindow } = require('electron')
var couchbase = require('couchbase');
function createWindow () {
What I have tried already:
removing the node_modules directory and lock file and reinstalling via npm i
installing and running electron-rebuild
using the --update-binary switch when running npm i
downgraded the npm version to an LTS version
Background information:
Node version:
PS C:\dev\app> node --version
v12.16.1
PS C:\dev\app> electron --version
v8.0.1
Electron uses node 12.13.0:
We are using node 12.13.0, Chrome 80.0.3987.86, and Electron 8.0.1.
The version of electron-node and standalone node differ. I am not sure if this is okay?!
Content of my package.json file:
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"couchbase": "^3.0.0",
"electron": "^8.0.1",
"electron-rebuild": "^1.10.0"
},
"dependencies": {
"node-gyp": "^6.1.0"
}
}
Similar questions:
Couchbase Node compiled against different node version: After I have added a comment I discovered that it is a unix specific question.
Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51: I went through nearly all of the suggestions, but none of them seemed to work for me.
I created an Outlook WEB Add-in from Visual Studio. I want to continue with VS Code to develop the project, but how to start it and debug? I stumbled across this articles by Microsoft:
https://code.visualstudio.com/docs/other/office
https://developer.microsoft.com/en-us/office/blogs/creating-office-add-ins-with-any-editor-introducing-yo-office/
Downloaded and installed both node.js and Yeoman and managed to create a new Office project with them, using VS Code. Ok, but how to run already created project with Visual Studio that has kind of different folder structure? I loaded the project with VS Code and when I started debug process and add the following configuration:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\MyAddInWeb\\Login.js"
}
]
}
I get the following errors:
Debugger listening on
ws://127.0.0.1:44392/d1234530-8653-45d8-8634-b28355329cee For help,
see: https://nodejs.org/en/docs/inspector Debugger attached.
c:\Users\mydir
Workplace\src\MyAddIn\MyAddInWeb\Login.js:5
Office.initialize = function (reason) {
^
ReferenceError: Office is not defined
at c:\Users\mydir\src\MyAddIn\MyAddInWeb\Login.js:5:5
at Object. (c:\Users\mydir\src\MyAddIn\MyAddInWeb\Login.js:109:3)
at Module._compile (internal/modules/cjs/loader.js:698:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) Waiting for ReferenceError: Office is not defined Login.js:5
at c:\Users\mydir\src\MyAddIn\MyAddInWeb\Login.js:5:5
at Object. (c:\Users\mydir\src\MyAddIn\MyAddInWeb\Login.js:109:3)
at Module._compile (internal/modules/cjs/loader.js:698:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) the debugger to disconnect...
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.
I can't seem to figure out why this works locally fine, but when I push it to Heroku it fails with the following error.
Error from Heroku
Starting process with command `node web.js`
module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module './proto'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (/app/node_modules/express/node_modules/connect/lib/connect.js:14:13)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Module.require (module.js:359:17)
Process exited with status 1
State changed from starting to crashed
package.json
{
"name": "divtest",
"version": "0.0.2",
"dependencies": {
"underscore": "1.3.x",
"crypto": "0.0.x",
"knox": "0.3.x",
"mongoose": "~3.1.2",
"mime": "1.2.x",
"express": "3.0.x",
"request": "~2.9.203"
},
"engines": {
"node": "0.6.x",
"npm": "1.0.x"
}
}
./proto is a local module that connect is calling
I've blown away my ./node_modules folder and did a npm install --save and still get the same results.
I had this issue, and my problem was that I'm a git beginner and hadn't properly committed all of the files that were needed. It looks like there was a proto.js in connect somewhere.
I did a git add * (...) and pushed again and it all went nicely.
Another telling error, was that on push Heroku complained about unmet dependencies.