-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Problems with graceful-fs/polyfills.js : process.version "undefined" #196
Comments
Here is a workaround I came across: const { remote } = window.require('electron');
const fs = remote.require('fs-extra'); Just replace |
Hi @TrueFusion I do not understand what I should do. In src/services/electron-services/database/index.ts I tried to substitute
with
but got "Cannot find module 'fs-extra/pathExistsSync' or its corresponding type declarations" |
I couldn't provide you with relevant code because I didn't know what exactly you were trying to do. But if you were trying to use the In other words, this code import fs from 'fs-extra' Becomes this code const { remote } = window.require('electron');
const fs = remote.require('fs-extra'); Then you can start using const { remote } = window.require('electron');
const fs = remote.require('fs-extra');
if (!isRenderer) {
if (!fs.pathExistsSync(STORE_PATH)) {
fs.mkdirpSync(STORE_PATH)
}
} I don't know where |
@TrueFusion where does window come from? |
|
@TrueFusion
But I got this error:
actually window, aka win, is already defined in src/background.ts :
But window has to be defined in src/services/electron-services/database/index.ts as well in order to be able to do |
The moment you redefine Here may be a good place to start: https://developer.mozilla.org/en-US/docs/Web/JavaScript |
@TrueFusion thank for your kind suggestion. |
@TrueFusion thank you for your pull request
I get : "ReferenceError: window is not defined". |
How are you compiling your code? And how are you running your app? |
This is the complete output:
|
Your |
This is the preload.js I'm using, based on the suggestions here: electron/electron#9920 (comment)
How should I modify preload.js in order to properly launch electron? I tried also with nodeIntegration:true in src/background.ts, thus commenting the preload.js path :
but still get error: "ReferenceError: window is not defined" |
This is as far as I will help you on the matter. https://www.electronjs.org/docs/tutorial/quick-start For anything else, you'll have to become more acquainted with web technologies. |
Thank you very much for your kind valuable contribution
Il gio 17 set 2020, 21:11 truefusion <notifications@github.com> ha scritto:
… This is as far as I will help you on the matter.
https://www.electronjs.org/docs/tutorial/quick-start
For anything else, you'll have to become more acquainted with web
technologies.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#196 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQYOI2YP3K2UI2KVKIDM5RTSGJNPBANCNFSM4Q2YKXCA>
.
|
I have the same problem: Uncaught TypeError: can't access property "match", e.version is undefined I've tried everything under the sun, and don't think it's my npm installation. Let me know if you would like more info. Meanwhile I'm going to try commenting out: if (constants.hasOwnProperty('O_SYMLINK') && which seems to be the problem area so far. Edit: Ok, I tried editing out the above, and it worked for that problem, but then something similar, same file - shows up. Which makes me think it's not this file at all, but something else. I had just added this package to read ssl cert/key with. Before that the project was fine running under http. |
i faced the same issue and fixed it by downgrading to graceful-fs "4.2.4" version; force it using 'npm install graceful-fs@4.2.4' |
Edit: Ok I my miss take if you remove the line "implementation: require('sass'),". Then sass-dart will be loaded and it will work. If sass is used, it failed already in require('sass') because someone require('fs') is used which return an empty object. This happend only in the browser. |
webpack config, try this, may worksI am using webpack & electron.js plugins: [
// https://webpack.js.org/plugins/environment-plugin/
new webpack.DefinePlugin({
'process.version': process.version,
}),
], Above solution cause some other problem(A lot of
|
Running into this as well with react on the latest version. Workarounds aren't really an option for my project.
for me the |
This problem is most likely caused by Webpack5. Webpack5 no longer automatically populates the nodejs core module. |
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 :
The operation setSettings has the same problem:
once I only activate setSettings in src/store/modules/app.ts I get the same error:
src/services/electron-services/setting/setting.ts :
Also modifying
still get this error
This is the line in fileSync.js which seems to be involved:
It seems that the line involved in node_modules/graceful-fs/polyfills.js is the following:
in this function:
vue info:
This is vue.config.js :
And this is webpack.config.js :
This is vue.config.js :
I've put in node_modules/graceful-fs/polyfill.js
console.log("process.version: ", process.version) :
And this is the output:
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
?
But this nodeIntegration: false shouldn't affect the node functioning and in particular the node's process version
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 ?
And why process.version is defined, thus not undefined in node_modules/graceful-fs/graceful-fs.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 ?
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
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: