Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: process is not defined #129

Open
fishpigbird opened this issue Feb 13, 2024 · 5 comments
Open

Uncaught ReferenceError: process is not defined #129

fishpigbird opened this issue Feb 13, 2024 · 5 comments

Comments

@fishpigbird
Copy link

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/[email protected]/dist/browser/pixi.min.js"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cubism4.min.js"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pixi.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/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/[email protected]/dist/browser/pixi.min.js"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cubism4.min.js"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pixi.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/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
Copy link

n0099 commented Feb 28, 2024

Same here

@guansss
Copy link
Owner

guansss commented Feb 28, 2024

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
Copy link

RaSan147 commented Mar 1, 2024

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
Copy link
Owner

guansss commented Mar 1, 2024

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

@RaSan147
Copy link

RaSan147 commented Mar 2, 2024

@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.

RaSan147 added a commit to RaSan147/CubismWebFramework that referenced this issue Apr 17, 2024
Addressing this issue guansss/pixi-live2d-display#129
(when server is not running with node)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants