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.

"Window is undefined" simply by importing pixi.js v4.0.3

See original GitHub issue

First of all I know default import isn’t defined in 4.1, so I’m using 4.0.3, until that is fixed.

Simply having a file with nothing but “import PIXI from ‘pixi.js’” causes a webgl error calling window:

/Users/funk/Development/Projects/jayeh_2015/node_modules/pixi.js/bin/pixi.min.js:17
"./ParticleBuffer":160,"./ParticleShader":162}],162:[function(t,e,r){function i(t){n.call(this,t,["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying float vColor;","void main(void){","   vec2 v = aVertexPosition;","   v.x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);","   v.y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);","   v = v + aPositionCoord;","   gl_Position = vec4((projectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vColor = aColor;","}"].join("\n"),["varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float uAlpha;","void main(void){","  vec4 color = texture2D(uSampler, vTexture

ReferenceError: window is not defined
    at Object.i.165../Math.sign (/source/src/particles/webgl/ParticleRenderer.js:403:1)
    at n (/source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1)
    at /source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1
    at Object.<anonymous> (/source/src/prepare/webgl/WebGLPrepare.js:181:1)
    at Object.i.170../accessibility (/source/src/prepare/webgl/WebGLPrepare.js:212:1)
    at n (/source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1)
    at t (/source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1)
    at /source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1
    at h (/source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1)
    at Object.<anonymous> (/source/node_modules/pixify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1)

I’m not even certain what pixify is… but this only happens when I import pixi.js. [Not it’s an isomorphic web app, which simply won’t render if typeof window is undefined.]

EDIT: I remapped to the non-minified version and got this instead:

/Users/funk/Development/Projects/jayeh_2015/node_modules/pixi.js/bin/pixi.js:30763
if(!window.ArrayBuffer){

EDIT: It looks like a lot of code needs to be wrapped…

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
themoonratcommented, Nov 16, 2016

You need to do import * as PIXI from 'pixi.js As englercj mentioned above. Reasons for no default export are given in this thread: https://github.com/pixijs/pixi.js/issues/3204

0reactions
lock[bot]commented, Feb 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Window is undefined" simply by importing pixi.js v4.0.3 #3224
First of all I know default import isn't defined in 4.1, so I'm using 4.0.3, until that is fixed. Simply having a file...
Read more >
Pixi JS - Reference Error: Window is not defined
Im using NodeJS and Pixi JS and I have this project Ive been working on for about a month just fine, but all...
Read more >
Building an Images Gallery using PixiJS and WebGL
This is the way PixiJS lets us execute custom shaders like the one we just created. // Init the gridded background function initBackground...
Read more >
react-pixi-fiber - npm
React Fiber renderer for PixiJS. Latest version: 1.0.4, last published: 2 months ago. Start using react-pixi-fiber in your project by ...
Read more >
8 Best Free and Open-Source JavaScript Game Engines and ...
PixiJS. PixiJS is one of the most popular libraries out there that you can use to create stunning graphics for your games.
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