Document not defined error

I am getting document not defined error when i am using,

I have included “dom” inside package.json lib.

[original thread by asvinwin123]

Hi, in which context?

You can only access DOM in browser context, i.e. from frontend extension entry module. It is not accessible from backend entry points or VS Code extensions (Theia plugins).


I am using in theia plugins frontend context


I am also getting navigator is not defined error

Plugins are never running in the main browser process, either in web worker or in Node.js process. Both don’t have access to DOM.

You can use webviews of VS Code extensions to integrate iframe in Theia or create a native Theia extension to have access to the DOM of main window.


@anton-kosyakov thank you


May i know how to access plugin from other extensions?

activate method can return an object which is accessible from other VS Code extension with vscode.extensions.getExtension(‘anotherPlugin’).exports


vscode or theia


can i have any sample code to see how to use?

Only VS Code extension can access another VS Code extension apis, native Theia extensions don’t have access to them.


Thank you @anton-kosyakov