guansss / pixi-live2d-display

A PixiJS plugin to display Live2D models of any kind.
https://guansss.github.io/pixi-live2d-display/
MIT License
810 stars 123 forks source link

Uncaught ReferenceError: process is not defined #129

Open fishpigbird opened 4 months ago

fishpigbird commented 4 months ago

How?

After I update the version of pixi.js and pixi-live2d-display with the same code, the browser reports an error:

<script src="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/pixi.js@6.5.2/dist/browser/pixi.min.js"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/pixi-live2d-display@0.4.0/dist/cubism4.min.js"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/pixi.js@7.x/dist/pixi.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/pixi-live2d-display@0.5.0-beta/dist/cubism4.min.js"></script>

Try to fix it.

<body>
    <canvas id=canvas></canvas>

<script>
//fix Uncaught ReferenceError: process is not defined
var process = {
    env: {
        NODE_ENV: 'production',

    }
};
</script>

<script src="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/pixi.js@6.5.2/dist/browser/pixi.min.js"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/pixi-live2d-display@0.4.0/dist/cubism4.min.js"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/pixi.js@7.x/dist/pixi.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/pixi-live2d-display@0.5.0-beta/dist/cubism4.min.js"></script>

<script>
const cubism4Model =
   "https://cdn.jsdelivr.net/gh/guansss/pixi-live2d-display/test/assets/haru/haru_greeter_t03.model3.json";
(async function main() {
  const app = new PIXI.Application({
    view: document.getElementById("canvas"),
    autoStart: true,
    resizeTo: window
  });
  const model4 = await PIXI.live2d.Live2DModel.from(cubism4Model);
  app.stage.addChild(model4);
  model4.scale.set(0.1);
  model4.x = 300;
})();
</script>
</body>

Question.

I wonder if that's my problem?

n0099 commented 4 months ago

Same here

guansss commented 4 months ago

Thanks for reporting! This is a bug that occurs when migrating from Webpack to Vite. The env variables should have been accessed from import.meta.env instead of process.env. I'll fix it soon.

RaSan147 commented 4 months ago

Thanks for reporting! This is a bug that occurs when migrating from Webpack to Vite. The env variables should have been accessed from import.meta.env instead of process.env. I'll fix it soon.

I probably did a patch on it... Care to check on my PR.

guansss commented 4 months ago

@RaSan147 I'm not sure which patch you mean, could you elaborate?

RaSan147 commented 4 months ago

@RaSan147 I'm not sure which patch you mean, could you elaborate?

nevermind, probably used some default value (I don't see it in my code anymore maybe forgot or something) Anyways, please do make a fix of it.