I've started the Realm-provided realm-electron-advanced-quickstart found here.
Everything works fine when running in dev, but when I package this with electron-builder, the app does not work. I moved createWindow() to the top of the app.whenReady() function so I could see the debugger, and it showed the following message:
Failed to open realm: Error: illegal operation on a directory
at run (renderer.js:26)
at renderer.js:39
Line 26 is
const realm = new Realm(config);
I suspect this is some sort of path/permissions issue with the .realm file.
In main.js, I changed the path in the realm config to
path.join(app.getPath("home"),"my.realm")
But I could not do so on renderer.js.
I would appreciate any ideas or examples of how this has been implemented before.
I'm running Node v14.15.4.
Related
I am building a react front Dapp on Ethereum blockchain.
I created it with create react app cmdline.
I have an issue with Metamask extension.
locally when I run my app on my computer everything is ok.
I run it locally with "npm start".
however, when I do "npm run build" to statically serve my app I get the following at first loading in the browser :
Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
Then when I refresh the page the error disappears and everything works well.
Some chrome extension devs are having same error with extensions. They solve it by handling the fact that the extension is not answering but in my case I use ethers.js library and I think a way to solve my issue is in the loading process of my app
the error appears when I make an async req to the Metamask extension :
const accounts = await ethereum.request({ method: 'eth_accounts' });
Any help please ?
EDIT
the issue is that the js scripts output from 'npm run build' command are written in the wrong place in the 'index.html' file generated by 'npm run build'(at the bottom)
When I manually put theses js scripts at the top of the 'index.html' file then my app is working.
But, I still need to find a solution to dynamicaly do this modification in the build process :
either an option argument in 'npm run build'
OR
a custom script to parse and modify the generated 'index.html'
any solution please ?
Summary
I'm new to Electron development, and helping to lead a small project at work creating an electron application. After working inside the Git repository for a day or so, the electron window suddenly stopped appearing. I've determined that the function callback I give in app.on('ready' callback) is never being called.
My workstation setup:
NodeJS version: 12.9.0 (Also tested with 10.16.3)
Yarn Version: 1.17.3
OS: Windows 10 Enterprise
Originally, I was loosely following Ryan Brockhoff's Medium post about using Electron with React when electron started malfunctioning, but I've since cut a brand new Git branch and set up only an extremely minimal Electron project, and the same problem appears.
Electron does not malfunction the same way system-wide. I'm able to run the electron-api-demos perfectly. In addition, an older test directory where I was experimenting with electron still functions.
When I attempt to run the broken electron repository, Task Manager does show three electron processes as children under the command line process. When I run a well-functioning electron process, the electron process is shown as a parent process
I confirmed the 'ready' callback function is never being called through placing console.log statements inside the function, as well as a print statement when the callback is being assigned. the callback assignment print statement is being reached, and I can see the output on the console, but the print statement inside the callback function is never being reached, and that output is never being printed to the console.
Troubleshooting
I've done many troubleshooting steps at this point:
Troubleshooting: I deleted and re-cloned the Git repository elsewhere on my computer
Result: problem persists
Troubleshooting: Let the program run for a while, maybe it needs to set something up before it's ready
Result: After 10+ minutes, no change
Troubleshooting: I downloaded the electron-api-demos repository to see if electron worked in that project
Result: electron-api-demos works perfectly as expected
Troubleshooting: I downgraded my electron version from "^6.0.3" to "^6.0.1", which works on a different project on my computer
Result: problem persists
Troubleshooting: I created a new empty Git branch, with no code and attempted to create a new minimal electron project in the same git repository I had been seeing the problem in
Result: problem re-emerges
Troubleshooting: Completely re-installed Node JS, changing versions from 12.x latest to 10.x LTS
Result: no change
Troubleshooting: cloned and attempted to run the project inside an Ubuntu Virtual Machine
Result: Success, project works as expected
Troubleshooting: Asked Co-worker to install project on their Windows 10 machine
Result: Success, co-worker could not re-produce my issue
Code
I set up an extremely minimal project to re-produce this issue. The following is my current project:
package.json
{
...
"main": "main.js",
"scripts": {
"electron-start": "electron ."
},
"devDependencies": {
"electron": "^6.0.3"
},
...
}
main.js
const {app, BrowserWindow} = require('electron')
function createWindow () {
console.log("inside the on ready callback"); //for troubleshooting
win = new BrowserWindow({width: 800, height: 600})
win.loadFile('index.html')
}
console.log("outside the function"); //for troubleshooting
app.on('ready', createWindow)
index.html
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Hello World!</h1>
</body>
</html>
When I run yarn electron-start, the following prints out to my console:
yarn run v1.17.3
$ electron .
outside the function
The print statement for inside the on ready callback is never reached. No errors are being emitted.
Conclusion
At this point, my suspicion is that there is something on my computer that is messed up. The Git repository that this code runs inside seems to be causing problems as well. I've done a lot of googling and I can't find anyone else facing this problem. The only thing I can think from here is to try scrapping our entire git repository and creating a new one (which may or may not be possible), and taking my computer into tech support for a possible replacement. Any clues on how to move forward would be greatly appreciated. Thanks
Alright, so I eventually did find a solution to this. This error was caused by attempting to install extra devtools using electron-devtools-installer. I found that the error was caused by data being left over in the %AppData%/electron directory, and the %AppData%/[projectname] directory. Deleting these two directories solves this issue.
Workaround: Call app.removeAllListeners('ready') before app.on('ready', createWindow)
I'm trying to run Heroku applications locally via 'heroku local,' but a missing module error is occurring in the Heroku CLI. Is this a Heroku bug that just needs to be reported or is there something wrong with how things have been setup on my machine (mac)? Any suggestions are appreciated.
In order to ensure my application isn't the problem, I've been debugging this issue with the node application Heroku provides in its getting started guides. Meaning, it already has a Procfile that can be run using default settings.
Things I've tried:
Re-install node modules for both application and CLI
Re-install the Heroku CLI
Here's the error:
node-js-getting-started [master] :> heroku local
Error: Cannot find module '../../load-foreman-procfile'
at Object.<anonymous> (/usr/local/Cellar/heroku/7.26.1/libexec/node_modules/#heroku-cli/plugin-local/lib/commands/local/index.js:5:18)
The file for the route above requires a 'load-foreman-procfile' like so:
const Procfile = require('../../load-foreman-procfile');
That require path doesn't lead to a to file by that name. In fact, this is the only reference to 'load-foreman-procfile' I can find in '/usr/local/Cellar/heroku/7.26.1'.
Rather than the error code above, I would expect heroku local to yield a running local server started via my Procfile.
I got the same error running heroku-cli v7.26.0. I switched to their edge channel (currently v7.26.2) and heroku local worked for me after that.
like #sophon mentioned - updating from v7.26.0 to v7.26.2 solved this for me. heroku update on mac did the trick.
I am trying to assist in setting up AppDynamics with an Angular 2 app that is hosted in IIS. The app is already up and running. There is a part I am having trouble on, the instructions for that part say say:
1) From the root directory of your Node.js application, run this command:
npm install appdynamics#4.3.5
For every Node.js application you are instrumenting, insert the following call in the application source code at the first line of the main module (such as the server.js file), before any other require statements:
require("appdynamics").profile({
controllerHostName: '<controller host name>',
controllerPort: <controller port number>,
controllerSslEnabled: false, // Set to true if controllerPort is SSL
accountName: '<AppDynamics_account_name>',
accountAccessKey: '<AppDynamics_account_key>',
applicationName: 'your_app_name',
tierName: 'choose_a_tier_name',
nodeName: 'choose_a_node_name'
});
2) Restart you application
I did step 1 locally in the console, but I don't know what to do for step 2. If I add that script to the page I get "The Reference error: require is not defined".
I learned that that function is not meant to run on the browser. It's meant to be run server-side, but I do not see node js or any server.js files on our dev web server.
Does anyone have any suggestions on where to put that snippet. Will it even work with the current setup?
It turns out the code I was given was completely wrong for angular 2 implementation. The code they gave me is for running on the web server's side with node js. Since angular 2 is an SPA that runs on the browser, it would never work.
I did some research and found this example application that I added a few tweaks to: https://github.com/derrekyoung/appd-sampleapp-angular2
I am using Ubuntu 16.04 x 64 and I'm running into an issue -
When I run my Keystone JS app manually by typing in "node keystone", the app runs fine and I can view it in my browser like normal.
However, when I start the app using pm2, the app fails immediately and restarts consecutively.
I think it is because keystonejs has a known "error" that is not a real error, but just a warning when it starts.
From the "keystone-out-0.log" file -
Error ...node_modules/bson/build/Release/bson.node: invalid ELF header
However, in the "keystone-error-0.log" file, it gives me a different error that does not occur when I run it manually -
Error: ENOENT: no such file or directory, open '.env'
Any one faced anything similar?
Thanks