AUR0722

Invalid platform object provided to the compilation, no DOM API found.

Error message

Invalid platform object provided to the compilation, no DOM API found.

Parameters

None

Error explanation

This error occurs during the template compilation setup when the compiler cannot access a valid Document Object Model (DOM) API through the provided platform object. The template compiler requires access to standard DOM features (like document, createElement, etc.) to parse and process HTML templates. This error indicates that the environment where the compilation is happening is missing these essential DOM APIs or that the platform abstraction used by Aurelia was not correctly initialized with them.

Common causes

  • Running the template compiler in a non-browser environment (e.g., Node.js) without providing a DOM implementation (like jsdom).

  • Incorrectly configuring or initializing the Aurelia IPlatform service in a custom setup.

  • An issue with the environment's global document object if running in a browser-like context.

How to fix

  • Browser Environment: Ensure you are running the application in a standard browser environment where window.document is available.

  • Node.js/SSR Environment: If compiling templates outside a browser, ensure a DOM implementation (like jsdom) is correctly configured and provided to Aurelia's platform abstraction before compilation occurs. Refer to Aurelia's Server-Side Rendering (SSR) documentation for guidance.

  • Custom Platform: If using a custom IPlatform implementation, verify that it correctly provides access to a functional DOM API, including a document object with standard properties and methods.

Debugging tips

  • Verify the execution environment (browser vs. non-browser).

  • If in Node.js, check your DOM simulation setup (e.g., jsdom initialization).

  • Inspect the IPlatform service registered in the DI container to ensure it holds a valid DOM reference.

Last updated

Was this helpful?