Your software
My Mautic version is: 5.0.1
My PHP version is: 8.1
NPM build exits with error code 137
M5 needs to build static assets with NPM. The NPM build process consumes too many resources/RAM and gets killed by the web server resulting in an error code 137.
My instance is on a shared hosting, but I can use 1.5GB of RAM
Terminal output
$ npm ci --prefer-offline --no-audit
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
> mautic@0.0.0 postinstall
> node_modules/modernizr/bin/modernizr -c modernizr-config.json -d node_modules/modernizr/modernizr-mautic-dist.js & npm run build
Modernizr build saved to node_modules/modernizr/modernizr-mautic-dist.js
> mautic@0.0.0 build
> webpack --mode production --config webpack.config.js
sh: line 1: 1563 Killed npm run build
npm ERR! code 137
npm ERR! path /var/www/mautic
npm ERR! command failed
npm ERR! command sh -c node_modules/modernizr/bin/modernizr -c modernizr-config.json -d node_modules/modernizr/modernizr-mautic-dist.js & npm run build
To me 1.5GB RAM seems plenty. Are there other factors at play?
Is there a way to optimize the build process?
Current workaround
My current workaround is:
- rsync my instance on my local machine
- run the npm build
- sync back
cd /tmp
mkdir mtc
cd mtc
rsync -avz -e 'ssh -i ~/.ssh/id_rsa' user@domain.com:/var/www/mautic/ .
npm ci --prefer-offline --no-audit
npx patch-package
rsync -avz -e 'ssh -i ~/.ssh/id_rsa' . user@domain.com:/var/www/mautic