Skip to content

Vite: "Uncaught TypeError: Cannot read properties of undefined (reading 'Rive')" #342

@mandrasch

Description

@mandrasch

Description

Hi! I'm just getting started with Rive.

I wanted to create a simple demo with Vite (vanilla-ts) and I ran into the following error locally:

Uncaught TypeError: Cannot read properties of undefined (reading 'Rive')
    at main.ts:30:22

Line 30, main.ts:

const canvas = document.getElementById("canvas") as HTMLCanvasElement|null; 
if(canvas !== null){
  const r = new rive.Rive({

I found another post on Discord, same error: Discord Post

I suspect this is because I'm trying to play a Rive file before the WASM file is loaded. But how do I check if that file is loaded?

Provide a Repro

The production build works fine though: https://rive-vite-demo.vercel.app/

Source .riv/.rev file

Expected behavior

  • No error, Rive should load locally on Vite for local development

Screenshots

image

Browser & Versions (please complete the following information)

  • Browser: Chrome Stable 120
  • OS: macOS 13.5.2
  • NPM Version: 9.8.0

Additional context

Thanks in advance for any hints! 👋 Cheers! 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions