-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'match' of undefined : const stateRecord: App = loadSettings() #304
Comments
@raphael10-collab Hey, thanks for your using. You first confirm whether all operations on the database will have this problem, and check again if |
Hi @ysfscream thanks for helping. I discovered that also the operation setSettings has the same problem:
src/services/electron-services/setting/setting.ts :
What does it mean if db.json is indeed created in the corresponding path?
-rw------- 1 marco marco 20K set 4 10:51 Cookies (base) marco@pc01:~/.config/base$ nano db.json :
|
Means to check whether
- const adapter: Lowdb.AdapterSync<Schema> = new FileSync<Schema>(path.join(STORE_PATH,
'/db.json'))
+ const adapter = new FileSync('db.json')
|
I removed webpack.config.js, removed node_modules folder, executed yan in order to re-install node_modules, and modified in src/services/electron-services/database/index.ts
and still get this error: This is the line in fileSync.js which seems to be involved: |
I've put in node_modules/graceful-fs/polyfill.js
And this is the output:
What is this "process"? And why its version is undefined? |
So this should be the problem.
https://nodejs.org/api/process.html#process_process About process, you can refer to the |
node is working fine:
May be this version "undefined" is due to the fact that I set, to keep the app as safe as possible, nodeIntegration: false in
? I searched in graceful-fs folder for all the occurences of process.version :
Why process.version is "undefined" in node_modules/graceful-fs/polyfills.js ? If I put console.log in:
in node_modules/graceful-fs/graceful-fs.js I do not get any output... Putting console.log(process) in node_modules/graceful-js/polyfill.js :
I get :
plenty of other output at the end of which :
So, it seems that process.version used by node_modules/graceful-fs/polyfill.js is: v12.16.3 Why the print of console.log("process.version: ", process.version) gives "undefined" and not v12.16.3 ? |
OK, I think this should be the reason for this error.
The https://www.electronjs.org/docs/api/browser-window#new-browserwindowoptions
Enabling nodeIntegration only imposes risks if you load and execute code from untrusted sources, i.e. the internet or from user input. So you can set it to |
I've put nodeIntegration: true in src/background.ts :
but still get the same error: "Uncaught TypeError: Cannot read property 'match' of undefined" Anyway, as far as I understand, to keep electron.js app safer nodeIntegration: false in conjunction with the use of preload file should be preferred: https://www.electronjs.org/docs/tutorial/security#electron-security-warnings I do not understand why process.version is "undefined" in node_modules/graceful-fs/polyfill.js but when printed outside of polyfill.js is v12.16.3 |
Well, now I can only provide a few debug ideas for reference, because I don’t know why and I can’t reproduce this issue. Sorry about that.
|
I just updated the repo of this simple project: https://github.com/raphael10-collab/ElectronVueTypeScriptScaffolding, which is downloadable, and I already opened an issue under graceful-fs.js repository: isaacs/node-graceful-fs#196 I'm trying to understand where process.version is set to undefined, but till now I didn't find it. I'm wondering why you don't have any issues about this aspect. Anyway, thank you very much for your kind help. |
@ysfscream in isaacs/node-graceful-fs#196 I was suggested to change in /src/services/electron-services/database/index.ts the way to import electron and fs-extra : const { app, remote } = window.require('electron') But I do not understand how to define window in /src/services/electron-services/database/index.ts |
Sorry, I cloned your project and want to run it for testing, but an error occurred. App threw an error during load
ReferenceError: window is not defined
at eval (webpack:///./src/services/electron-services/database/index.ts?:8:25)
at Module../src/services/electron-services/database/index.ts (/Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:1894:1)
at __webpack_require__ (/Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:20:30)
at eval (webpack:///./src/background.ts?:7:100)
at Module../src/background.ts (/Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:1870:1)
at __webpack_require__ (/Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:20:30)
at eval (webpack:///multi_./src/background.ts?:1:18)
at Object.0 (/Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:1917:1)
at __webpack_require__ (/Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:20:30)
at /Users/yushifan/Documents/GitHub/ElectronVueTypeScriptScaffolding/dist_electron/index.js:84:18 |
Hi @ysfscream !!! The error "window is not defined" was due to these lines that I now commented in /src/services/electron-services/database/index.ts : //const { app, remote } = window.require('electron') Now with these lines commented we have the usual error "Cannot read property'match' of undefined which is the error we are trying to solve. I updated and committed the github repo: https://github.com/raphael10-collab/ElectronVueTypeScriptScaffolding.git Thank you very much for helping!!! |
This is great!! Hope you can have a good development experience. I will close this issue :) |
@ysfscream Have you figured out how to solve this problem? |
Actually, I didn’t fully understand. Did you replace |
The code which causes the error: "Cannot read property 'match' of undefined" should be placed in this file: But I do not know how to solve it |
Write the following in vue.config.js: .... configureWebpack: { ... } |
It doesn't work at all |
I'm using your excellent electron app as starting point to understand how to implement a vue,.js - electron.js app in a totally different use-case.
I'm encountering this problem:
I discovered that once I activate this line:
const stateRecord: App = loadSettings()
in /src/store/modules/app.ts
I get this error: "Cannot read property 'match' of undefined"
This is /src/store/modules/app.ts :
this is src/services/electron-services/setting/setting :
and this is electron-services/database/index.ts :
Environment Info:
This is vue.config.js :
And this is webpack.config.js :
What could be the cause of this "Cannot read property 'match' of undefined"? What's wrong with this function in class DB ?:
You can find the GitHub repo here: https://github.com/raphael10-collab/ElectronVueTypeScriptScaffolding
Looking forward to your kind help
The text was updated successfully, but these errors were encountered: