Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Forked from PeterHancock/README.md
Created April 23, 2017 18:27
Show Gist options
  • Save wmakeev/c3ed6893fc042ed601ad00eb69d97cb0 to your computer and use it in GitHub Desktop.
Save wmakeev/c3ed6893fc042ed601ad00eb69d97cb0 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment