title: How to increase NodeJS heap (--max-old-space-size) in Bitbucket Pipelines for Typescript/Webpack?
body: <p>I am running into memory issues during the webpack packaging step in a serverless/TypeScript project. </p>
  
  <p>I have tried: </p>
  
  <ul>
  <li>'increase-memory-limit' npm package to no avail</li>
  <li><p>Calling the following command from an npm run script</p></li>
  <li><p>Calling the following command directly through bitbucket-pipelines.yml. </p>
  
  <pre><code>node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy
  </code></pre></li>
  </ul>
  
  <p>It works fine locally with this command, but in Bitbucket pipelines I get the following output:</p>
  
  <pre><code>    Serverless: Bundling with Webpack...
  
      internal/child_process.js:323
          throw errnoException(err, 'spawn');
          ^
      Error: spawn ENOMEM
          at _errnoException (util.js:1022:11)
          at ChildProcess.spawn (internal/child_process.js:323:11)
          at exports.spawn (child_process.js:502:9)
          at Object.exports.fork (child_process.js:103:10)
          at fork (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/fork.js:17:36)
          at Farm.startChild (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:106:16)
          at Farm.processQueue (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:279:10)
          at Farm.&lt;anonymous&gt; (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:97:21)
          at ontimeout (timers.js:475:11)
          at tryOnTimeout (timers.js:310:5)
          at Timer.listOnTimeout (timers.js:270:5)
      npm ERR! code ELIFECYCLE
      npm ERR! errno 1
      npm ERR! platform-state-machine-import@0.0.2 deploy: `node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy "--stage"    "feattsify" "--region" "us-east-1"`
      npm ERR! Exit status 1
      npm ERR! 
      npm ERR! Failed at the platform-state-machine-import@0.0.2 deploy script.
      npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
      npm ERR! A complete log of this run can be found in:
      npm ERR!     /root/.npm/_logs/2019-02-07T22_37_25_150Z-debug.log
  </code></pre>
  
  <p>I've done a lot of googling and searching here to try to find if Bitbucket has some kind of env. variable you can set for runtime args, etc., but can't seem to find anything that doesn't tie back into the aforementioned NPM package.</p>