Running Meteor by npm run - CPU issue workaround


as many people probably noticed, there is issue when running meteor using npm run.
That means that you prepare scripts in package.json so the simple command run meteor with many arguments and you does not have to write it all by hand every time.

But seems current node I/O streams are somehow not compatible with meteor’s internal node I/O.
So it end up with like 170% of constant CPU consumption by node on my 4 core.

For this you you need to use older node to call that npm.
That can be done by installing nvm and switching to old node version.

As we need to run also chimp and I would prefer still to use current npm version by default so I prepared little wrapper for brew installed nvm on my OSX.

Roberts-MacBook-Pro:~ shock$ cat .bash_profile

export NVM_DIR=~/.nvm
. /usr/local/opt/nvm/
alias npm="~/"

Roberts-MacBook-Pro:~ shock$ cat


readonly METEOR_NODE_VERSION="0.10.40"

# source nvm script installed by brew
. /usr/local/opt/nvm/

if [[ "$1" == "run" && ( "$2" == "start" || "$2" == "testEnv" ) ]]
  echo "Using npm for $METEOR_NODE_VERSION"
  nodePath=$(nvm which $METEOR_NODE_VERSION)
  npmPath=$(echo $nodePath | sed 's/node$/npm/')
  exec "$npmPath" $@
  # exec with current node
  nodePath=$(nvm which current)
  npmPath=$(echo $nodePath | sed 's/node$/npm/')
  exec "$npmPath" $@

echo "Something went horribly wrong in"
exit 1

Link to meteor issue

1 Like