I always want to run Node.JS with the
--harmony flag. Is there a way to easily have this flag turned on by default?
(Note: I'm running on Windows, so I only have access to Cygwin or Mingw as shells.)
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
If you are talking about running interactively, you can use a bash
alias. Put this in your
alias node="node --harmony"
(For the below: note that when I say "executable", I don't just mean binaries or ".exe files". "Executables" include anything that can be executed without explicitly invoking an interpreter, which includes scripts with a shebang.)
If you want to run an executable, e.g. within another script, you can create a shell script that launches the target with the extra flag:
nodeHarmony and put it in your search path, e.g.
#!/bin/sh node --harmony "$@"
chmod a+x it.
nodeHarmony whenever you want that flag appended. If you want to replace the
node executable, you could probably rename
node to something else (e.g.
node_original), name the script
node, and use
node_original within the script.
You could also create the equivalent Windows batch script, which would work outside Cygwin/MinGW:
@echo off node --harmony %*
This would behave similarly, but may exhibit odd effects with some argument combinations, because the list would get parsed twice - once when executing the batch script, and once within the script when executing
node. Some workarounds here.
If you are ready to recompile node.js, the article How to obtain harmony in your node.js says :
Once you’ve got the source code, open up
deps/v8/src/flag-definitions.hand look for Line 115. Change the flag from false to true :
DEFINE_bool(harmony, true, "enable all harmony features")
Then compile Node :
./configure && make && make install