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?
Join Stack Overflow to learn, share knowledge, and build your career.
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.
which gulp
) is named. This should end up in an error, since which gulp
will resolve to gulp: aliased to node --harmony `which gulp`
– naeramarth7
Apr 16 '15 at 16:08
which gulp
even after an alias, returns the actual path to a gulp binary. You can check it by your own, it is just works.
– FelikZ
Apr 17 '15 at 8:41
zsh
on OS X 10.10
(besides the missing quote on the alias line). Gives me Error: Cannot find module '<path to current folder>/gulp'
since it tries to run exactly this command: node --harmony gulp: aliased to node --harmony `which gulp`
.
– naeramarth7
Apr 17 '15 at 8:47
gulp any-task
commands and vanilla gulp
. I ran it in GNOME terminal 3.6.2, on 64-bit Linux Mint 17.1.
– Andrew Faulkner
Aug 28 '15 at 8:18
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:
gulp [options for gulp] -- --harmony
, where everything after--
should be passed to Node.js . – Robert Rossmann Apr 16 '15 at 13:55