Skip to content

Commit

Permalink
Add NODE_OPTIONS env var to npm install
Browse files Browse the repository at this point in the history
part of #194
  • Loading branch information
hardillb committed Nov 20, 2023
1 parent f73d4a2 commit 7f3e248
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,15 @@ class Launcher {
fs.writeFileSync(pkgFilePath, JSON.stringify(pkg, null, 2))
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
return new Promise((resolve, reject) => {
const env = {}
if (this.settings.stack.memory) {
const memLimit = Math.round(this.settings.stack.memory * 0.75)
env.NODE_OPTIONS = `--max-old-space=${memLimit}`
}
const child = childProcess.spawn(
npmCommand,
['install', '--omit=dev', '--no-audit', '--no-update-notifier', '--no-fund'],
{ windowsHide: true, cwd: path.join(this.settings.rootDir, this.settings.userDir) })
{ windowsHide: true, cwd: path.join(this.settings.rootDir, this.settings.userDir), env })
child.stdout.on('data', (data) => {
this.logBuffer.add({ level: 'system', msg: '[npm] ' + data })
})
Expand Down

0 comments on commit 7f3e248

Please sign in to comment.