# NPM build process is resource hungry

**URL:** <https://forum.mautic.org/t/npm-build-process-is-resource-hungry/30530>\
**Category:** Mautic 5 Install/Upgrade Support\
**Created:** [January 17, 2024, 9:25am UTC](https://forum.mautic.org/t/npm-build-process-is-resource-hungry/30530 "2024-01-17T09:25:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter\_k](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/peter_k/32/511_2.png) [@peter\_k](https://forum.mautic.org/u/peter_k)\
**Post date:** [January 17, 2024, 9:25am UTC](https://forum.mautic.org/t/npm-build-process-is-resource-hungry/30530/1 "2024-01-17T09:25:52Z")

</div>

**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

```bash
$ 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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Chris76](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/chris76/32/522_2.png) [@Chris76](https://forum.mautic.org/u/Chris76)\
**Post date:** [February 3, 2024, 4:31am UTC](https://forum.mautic.org/t/npm-build-process-is-resource-hungry/30530/2 "2024-02-03T04:31:51Z")

</div>

Just wondering:  
Is this a workable workaround?  
I can install Mautic on a local virtual box and then sync it into the hosting environment without NPM installed?  
Or does Mautic require NPM for standard operation as well? (or only during installation?)

---

<div class="post-metadata">

**Author:** ![peter\_k](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/peter_k/32/511_2.png) [@peter\_k](https://forum.mautic.org/u/peter_k)\
**Post date:** [February 8, 2024, 11:10am UTC](https://forum.mautic.org/t/npm-build-process-is-resource-hungry/30530/3 "2024-02-08T11:10:00Z")

</div>

I’m not that deep into Mautic development, but NPM _per se_ should not be necessary to run Mautic.

It just builds the assets.

That’s why running the build process locally and rsyncing the outcome to the server works for me.

---

<div class="post-metadata">

**Author:** ![sdoering](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/sdoering/32/8909_2.png) [@sdoering](https://forum.mautic.org/u/sdoering)\
**Post date:** [April 3, 2024, 11:28am UTC](https://forum.mautic.org/t/npm-build-process-is-resource-hungry/30530/4 "2024-04-03T11:28:28Z")

</div>

I am currently experiencing the same issues. Same error, same resource hungry process being killed on German hoster uberspace (shared hosting).

Commenting to raise this again.
