I have a simple app just for testing Meteor and Pixi.js.
My main.jsx (the only script file):
import { Meteor } from 'meteor/meteor';
import React from 'react';
import {render} from 'react-dom';
import PIXI from 'pixi.js';
Meteor.startup(()=>{
render(
<p>zdzdzd</p>,
document.getElementById('container')
);
});
But have an error when importing PIXI
graceful-fs.js:157 Uncaught TypeError: Cannot read property 'prototype' of undefined
patch @ graceful-fs.js:157
meteorInstall.node_modules.graceful-fs.graceful-fs.js @ graceful-fs.js:27
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.glslify-deps.index.js @ index.js:2
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.glslify.index.js @ index.js:3
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.pixi.js.src.core.renderers.webgl.filters.spriteMask.SpriteMaskFilter.js @ SpriteMaskFilter.js:5
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.pixi.js.src.core.renderers.webgl.managers.MaskManager.js @ MaskManager.js:2
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.pixi.js.src.core.renderers.webgl.WebGLRenderer.js @ WebGLRenderer.js:2
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.pixi.js.src.core.sprites.webgl.SpriteRenderer.js @ SpriteRenderer.js:2
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.pixi.js.src.core.index.js @ index.js:28
fileEvaluate @ install.js:153
require @ install.js:82
meteorInstall.node_modules.pixi.js.src.index.js @ index.js:4
fileEvaluate @ install.js:153
require @ install.js:82
Mp.import @ runtime.js:70
meteorInstall.client.main.jsx @ main.jsx:1
fileEvaluate @ install.js:153
require @ install.js:82
(anonymous function) @ app.js?hash=acf17d5…:42
What is the correct way to import it?
I'm not sure how you've installed your pixi package, but here are few options to get it working:
1) Via the npm pixi package (older now deprecated version):
a) Install it: meteor npm install --save pixi
b) Reference it as:
import pixi from 'pixi';
console.log(pixi);
2) Including a copy of the pixi.js
file with your app (approach to use with the newest version of pixi):
a) Download a copy of the pixi.js
file located on their github releases page .
b) Store the pixi.js
file in your apps /client/compatibility
directory.
c) Reference it as:
console.log(PIXI);
Actually it should be import * as PIXI from 'pixi.js';
pixi.js
just exports all the functions in the PIXI library directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.