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

We could not create the data directory #13

Open
etornam45 opened this issue Dec 11, 2024 · 5 comments
Open

We could not create the data directory #13

etornam45 opened this issue Dec 11, 2024 · 5 comments
Assignees

Comments

@etornam45
Copy link

image
This is the error I had by running this code

const { Application } = require('@webviewjs/webview');

class WebView {
    constructor(options = {}) {
        this.app = new Application();
        this.window = this.app.createBrowserWindow();
        this.webview = null;
    }

    loadHTML(html) {
        this.webview = this.window.createWebview({
            html: html
        });
    }

    show() {
        this.app.run();
    }
}

module.exports = WebView;
@twlite twlite self-assigned this Dec 13, 2024
@etornam45
Copy link
Author

image
Complete Screenshot

@twlite
Copy link
Member

twlite commented Dec 16, 2024

I'm not so sure about the error, how are you executing the code? is it via sea or is it direct? @etornam45

Also, does this happen with bun/deno as well?

@etornam45
Copy link
Author

I don't know anything about "sea or direct" but I tried using bun and it worked, I haven't tried deno yes

@nycki93
Copy link

nycki93 commented Jan 8, 2025

I'm having the same issue. It seems related to this thread: https://stackoverflow.com/questions/66374105/opening-webview2-in-wpf-causes-system-unauthorizedaccessexception-while-calling

My specifics:

  • Node v23.6.0
  • webviewjs v0.1.3

my code:

import { Application } from '@webviewjs/webview';

const app = new Application();
const window = app.createBrowserWindow();
const webview = window.createWebview();

webview.loadUrl('https://nodejs.org');

app.run();

Error log:

const webview = window.createWebview();
                       ^

Error: Failed to create webview: WebView2 error: WindowsError(Error { code: HRESULT(0x80070005), message: "Access is denied." })
    at file:///E:/nycki/Code/xp-webviewjs/app2.js:5:24
    at ModuleJob.run (node:internal/modules/esm/module_job:272:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:580:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5) {
  code: 'GenericFailure'
}

@nycki93
Copy link

nycki93 commented Jan 8, 2025

Workaround: Set the environment variable WEBVIEW2_USER_DATA_FOLDER to a writeable location.

import { Application } from '@webviewjs/webview';

process.env.WEBVIEW2_USER_DATA_FOLDER = process.cwd();

const app = new Application();
const window = app.createBrowserWindow();
const webview = window.createWebview();

webview.loadUrl('https://nodejs.org');

app.run();

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

3 participants