最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - PIXI.Application is not a constructor [PIXIJS] - Stack Overflow

programmeradmin4浏览0评论

i start a little project using pixijs. I follow that tutorial : but it doesn't work for me.

HTML :

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
</head>
    <script src="./node_modules.js/pixi.js/dist/pixi.min.js"></script>
<body>
    <script src="index.js" type="module"></script>
</body>

I got pixi module with the following mand : npm install pixi.js

index.js :

import * as PIXI from './node_modules/pixi.js/dist/pixi.min.js';

const log = console.log;
const app = new PIXI.Application();

Error :

PIXI.Application is not a constructor[En savoir plus] index.js:4:13
<anonyme>
http://localhost:3000/index.js:4:13
InnerModuleEvaluation self-hosted:4290:5 evaluation self-hosted:4243:9  

UPDATE

HTML :

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
</head>
<body>
    <script src="./node_modules.js/pixi.js/dist/pixi.min.js"></script>
    <script src="index.js" type="module"></script>
</body>
</html>

index.js :

const log = console.log;
const app = new PIXI.Application();

Error :

PIXI is not defined 

i start a little project using pixijs. I follow that tutorial : https://www.youtube./watch?v=FrnXCZmmAZo but it doesn't work for me.

HTML :

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
</head>
    <script src="./node_modules.js/pixi.js/dist/pixi.min.js"></script>
<body>
    <script src="index.js" type="module"></script>
</body>

I got pixi module with the following mand : npm install pixi.js

index.js :

import * as PIXI from './node_modules/pixi.js/dist/pixi.min.js';

const log = console.log;
const app = new PIXI.Application();

Error :

PIXI.Application is not a constructor[En savoir plus] index.js:4:13
<anonyme>
http://localhost:3000/index.js:4:13
InnerModuleEvaluation self-hosted:4290:5 evaluation self-hosted:4243:9  

UPDATE

HTML :

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
</head>
<body>
    <script src="./node_modules.js/pixi.js/dist/pixi.min.js"></script>
    <script src="index.js" type="module"></script>
</body>
</html>

index.js :

const log = console.log;
const app = new PIXI.Application();

Error :

PIXI is not defined 
Share Improve this question edited Oct 2, 2019 at 15:20 user128511 asked Aug 22, 2018 at 10:24 wyllisMonteirowyllisMonteiro 613 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

The tutorial doesn't use modules.

PIXI is exposed globally: https://github./pixijs/pixi.js/blob/v4.8.1/src/index.js#L51

If you remove the import, and fix the typo in the script tag, it should work.

HTML:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
</head>
<body>
    <script src="./node_modules/pixi.js/dist/pixi.min.js"></script>
    <script src="index.js" type="module"></script>
</body>
</html>

index.js:

const log = console.log;
const app = new PIXI.Application();

If you're using npm, I got this error cause I ran npm install pixi (incorrect) instead of npm install pixi.js (correct).

发布评论

评论列表(0)

  1. 暂无评论