The same could be achieved in node.js using --harmony
flag like this:
node --harmony app.js
So it will be add support for EcmaScript6.
How to run gulp commands with harmony flag?
A simpler solution would be to use harmonize : https://github.com/dcodeIO/node-harmonize
Just install harmonize and then require like so:
require("harmonize")();
You can do that in the following way:
alias gulp='node --harmony `which gulp`'
Place this in ~/.bashrc
file and gulp will always run in harmony mode.
If you are a docker user and want to use gulp
with harmony inside a container, you can do that in the following way:
docker run -ti \
--name container \
nodejs-image-with-gulp-pre-installed \
bash -ci 'gulp task'
The key is to use -i
flag with a bash, so your alias will be loaded successfully. Otherwise it will run gulp itself without harmony support.
To follow up on FelikZ's solution:
npm run
You can update your package.json
and add your gulp commands to the section scripts
:
{
"scripts": {
"start": "node --harmony `which gulp` start",
"build": "node --harmony `which gulp` build",
...
}
}
These commands can then be called with npm run start
, npm run build
etc.
If you want to call all your gulp commands through npm (without defining them separately) you can do as follows:
{
"scripts": {
"gulp": "node --harmony `which gulp`"
}
}
To run gulp start
, you would call npm run -- start
etc.
Alternative: io.js
If you want to use --harmony
by default, you could also have a look at io.js:
https://iojs.org/en/es6.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With