Skip to content

Instantly share code, notes, and snippets.

@ypetya
Last active October 11, 2016 17:57
Show Gist options
  • Select an option

  • Save ypetya/c999604922166aabcbed8edb1489c4f4 to your computer and use it in GitHub Desktop.

Select an option

Save ypetya/c999604922166aabcbed8edb1489c4f4 to your computer and use it in GitHub Desktop.
Fix out of javascript heap-memory isse for npm for mingw:npm extended with memory setupexport NODE_MEMORY=8000
#!/bin/sh
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
basedir=`dirname "$0"`
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
NODE_EXE="$basedir/node.exe"
if ! [ -x "$NODE_EXE" ]; then
NODE_EXE=node
fi
NPM_CLI_JS="$basedir/node_modules/npm/bin/npm-cli.js"
case `uname` in
*MINGW*)
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
fi
;;
*CYGWIN*)
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
fi
;;
esac
if [ ! "$NODE_MEMORY" == "" ] ; then
echo "$NODE_EXE" --max-old-space-size=$NODE_MEMORY "$NPM_CLI_JS" "$@"
"$NODE_EXE" --max-old-space-size=$NODE_MEMORY "$NPM_CLI_JS" "$@"
else
"$NODE_EXE" "$NPM_CLI_JS" "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment