Skip to content
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

import { app } from '@electron/remote'; in vue3 setup throws an error #168

Open
bluelemonade opened this issue Oct 19, 2023 · 0 comments
Open

Comments

@bluelemonade
Copy link

If got some error:

inside background.js

require('@electron/remote/main').initialize();

in the App.vue File

import fs from 'fs';
import pathModule from 'path'
import { app } from '@electron/remote';
import { onMounted, ref } from 'vue'; // onMounted,



export default {
  name: "app",

  setup() {

    const path = ref(app.getAppPath());
    console.log(path.value);

    onMounted(() => {
      
      try {
        fs.writeFileSync('myfile.txt', 'the text to write in the file', 'utf-8');
      } catch (e) {
        alert('Failed to save the file !');
      }
    });
	

these are the errors, when I comment the path and app lines out I can write a file in my working directory. I think the problem is the import of the app.

runtime-core.esm-bundler.js:41 [Vue warn]: Unhandled error during execution of setup function 
  at <App>
warn @ runtime-core.esm-bundler.js:41
app.js:470 Uncaught Error: @electron/remote is disabled for this WebContents. Call require("@electron/remote/main").enable(webContents) to enable it.
    at IpcMainImpl.eval (webpack:///./node_modules/@electron/remote/dist/src/main/server.js?:318:61)
    at IpcMainImpl.emit (node:events:514:28)
    at WebContents.<anonymous> (node:electron/js2c/browser_init:2:89402)
    at WebContents.emit (node:events:514:28)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant