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

Using Node v21 not supported: breaks on typeof navigator check #3047

Open
hewelt opened this issue Dec 4, 2023 · 6 comments
Open

Using Node v21 not supported: breaks on typeof navigator check #3047

hewelt opened this issue Dec 4, 2023 · 6 comments

Comments

@hewelt
Copy link

hewelt commented Dec 4, 2023

Tell us about your environment
Node v21.2.0

Browser and Browser Version:
n/a

After Effects Version:

n/a

What did you do? Please explain the steps you took before you encountered the problem.

I'm running remix serve command which starts my web application's runtime.

What did you expect to happen?

I expected the lottie-web code not to rely on typeof navigator to determine environment

What actually happened? Please include as much relevant detail as possible.

/Users/sebastian.hewelt/Code/xyz/node_modules/lottie-web/build/player/lottie.js:30
    return document.createElement(type);
    ^
ReferenceError: document is not defined

The code breaks because lottie.js checks for typeof navigator. This won't work anymore with Node.js v21+, because it's implemented navigator API. A discussion about other problems with it here.

The are many solutions options; one would be to find a more universal way to distinguish between environments, two - to check for document. 🙇🏻

@zolzaya
Copy link

zolzaya commented Jan 22, 2024

any updates?

@joeduncan
Copy link

A quick workaround is disabling the Navigator API in Node v21 with --no-experimental-global-navigator: https://nodejs.org/api/globals.html#navigator

@sunil013
Copy link

Is there any update regarding this? It's not working in the SSR case
Node - 21.6.2
Screenshot 2024-02-27 150438
Screenshot 2024-02-27 150417

@jlia0
Copy link

jlia0 commented Aug 13, 2024

this bug is literally keeping me up at night, so annoying, please fix

@simon-paris
Copy link

+1 I've also experienced this crash

@sourcec0de
Copy link

sourcec0de commented Oct 31, 2024

A quick workaround is disabling the Navigator API in Node v21 with --no-experimental-global-navigator: https://nodejs.org/api/globals.html#navigator

This was the solution to ReferenceError: document is not defined.
Node LTS enabled this partial implementation of the navigator API, which causes the Lottie module to think it's in the browser.

We added this with a temporary environment variable

NODE_OPTIONS="--no-experimental-global-navigator"

🙇 thanks @joeduncan

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

7 participants