I am making a game with Pixi.js and matter-js libraries. I am using Parcel Bundler (version 2.3.1) for HMR and bundling. The dev server works fine but when bundling for production the process crashes with following result:
/c/Program Files/nodejs/npm: line 44: 1511 Illegal instruction "$NODE_EXE" "$NPM_CLI_JS" "$@"
This is the command I used for starting the process (in build script in package.json):
parcel build src/index.html --dist-dir build --no-source-maps
This code reproduces the problem I am facing:
import {Application, Texture, Sprite} from 'pixi.js';
import grass from './grass.png?quality=75';
const app = new Application();
document.body.appendChild(app.view);
const grassTexture = Texture.from(grass);
const grassSprite = Sprite.from(grassTexture);
app.stage.addChild(grassSprite);
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<script type="module" src="script.js"></script>
</head>
<body>
</body>
</html>
This will, of course, not work here. But this works properly on dev server and produces same result on building.
On searching online I found a few solutions such as deleting package-lock.json
and node_modules
and then reinstalling them, but it did not work. I also completely uninstalled Node.js and reinstalled it but there was no difference.
If I import PNG as WebP it builds properly though loses some colours, so I assume this is a problem with saving PNGs. I would be content on using WebP if does not lose colours.
Thank you in advanced.