wmakeev
8/29/2015 - 10:34 AM

Running a node script on your $PATH with --harmony flag

Running a node script on your $PATH with --harmony flag

Running a node script on your $PATH but with the --harmony flag

Some npm packaged scripts are written as frameworks that dynamically require user node scripts, e.g. the gulp CLI script requires the user provided Gulpfile.js (by default).

To write .js using ES6 syntax is problematic; if the $PATH script for a framework x looks like

#!/usr/bin/env node
var x = require('x');

...

require('./x.js')(x);

how can we provide a x.js written in ES6?

Solutions

node --harmony `which <script>` [args]

Example

problem

You want to write your tape test.js written or depending on in ES6/2015 JS

solution

node --harmony `which tape` test.js