question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When attempting to use Lottie Player within a Shopify application... ReferenceError: window is not defined at Object.parcelRequire.eBH8../dom.js (.../node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:26:609

See original GitHub issue

I followed Shopify tutorial, for links to full tutorial see https://github.com/Shopify/shopify-demo-app-node-react

I amended to use heroku (also free, instead of ngrok… see instructions below) so that the application could always be up even when I am away with laptop shutdown.

Instructions on what I did:

  • git clone git@gitlab.com:Shopify/shopify-demo-app-node-react.git

  • cd shopify-demo-app-node-react

  • Install Heroku CLI

  • heroku login

  • heroku create **lottie-player** (might have to substitute ‘lottie-player’ for a unique name, also sub going forward with these instructions)

  • heroku git:remote -a **lottie-player**

  • See https://dashboard.heroku.com/apps/**lottie-player**/settings (app URL can be found on this page, e.g. “Your app can be found at https://lottie-player.herokuapp.com/”, remember to potentially sub in your app name for lottie-player)

The rest of the instructions are based on the official Shopify tutorial. No need to read the entire tutorial but it is recommended. What follows is a shortcut to get things up.

Question is, why would this work while the lottie-player implementation does not?

The debug log of failed deployment:

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:        
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:        
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.16.2...
remote:        Using default npm version: 6.14.4
remote:        
remote: -----> Restoring cache
remote:        - node_modules
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:        added 7 packages from 12 contributors and audited 7837 packages in 11.85s
remote:        
remote:        19 packages are looking for funding
remote:          run `npm fund` for details
remote:        
remote:        found 157 vulnerabilities (156 low, 1 moderate)
remote:          run `npm audit fix` to fix them, or `npm audit` for details
remote:        
remote: -----> Build
remote:        Running build
remote:        
remote:        > shopify-demo-app-node-react@1.0.0 build /tmp/build_d28b5bfecc417c7b58461cc77ef94a6f
remote:        > next build
remote:        
remote:        Creating an optimized production build ...
remote:        
remote: Browserslist: caniuse-lite is outdated. Please run next command `npm update`
remote: > Build error occurred
remote: ReferenceError: window is not defined
remote:     at Object.parcelRequire.eBH8../dom.js (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:26:609)
remote:     at f (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:468)
remote:     at p (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:544)
remote:     at Object.parcelRequire.bhxD.lit-html/lib/shady-render.js (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:34:557)
remote:     at f (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:468)
remote:     at p (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:544)
remote:     at Object.parcelRequire.M8c7.lit-element (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:42:180)
remote:     at f (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:468)
remote:     at parcelRequire.ytxR (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:771)
remote:     at Object.<anonymous> (/tmp/build_d28b5bfecc417c7b58461cc77ef94a6f/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js:1:1023)
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! shopify-demo-app-node-react@1.0.0 build: `next build`
remote: npm ERR! Exit status 1
remote: npm ERR! 
remote: npm ERR! Failed at the shopify-demo-app-node-react@1.0.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: 
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.s7Mom/_logs/2020-04-23T08_29_00_209Z-debug.log
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        Some possible problems:
remote:        
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to lottie-player.
remote: 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cgousleycommented, Sep 16, 2020

Same issue here, but not with Shopify.

0reactions
karamaliecommented, May 5, 2021

Closing due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

window is not defined (SSR) #2851 - airbnb/lottie-web - GitHub
This is a simple problem. On SSR builds importing lottie-web fails: ReferenceError (500) window is not defined open: ...
Read more >
ReferenceError : window is not defined at object. <anonymous ...
js I create a window variable called windowVar and I add to it some atrributes. In myModule.js ,I add some other attributes and...
Read more >
JavaScript Error on script load - LightJSExclude
Hi there, A client of ours ( empireskateshop.myshopify.com ) has noticed that our widget no longer loads on their website.
Read more >
Error while building Shopify Sample Embedded App
I'm using v13.8.0. Check by running node -v. If that doesn't work revert back any changes you made and delete node_modules folder and...
Read more >
Shopify App React and NodeJS tutorial - API_KEY not defined
Hi @tobrien,. The API_KEY value here is expected to be set as an environment variable within your app. One way of doing that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found