6

Generally, I make a nodejs file can execute directly with below style

#/usr/bin/env node
nodejs code here

But, when node 0.11 support generators, I try below

#/usr/bin/env node --harmony
nodejs code here

It output

/usr/bin/env: "node --harmony": No such file or directory
guilin 桂林
  • 17,050
  • 29
  • 92
  • 146

2 Answers2

4

You can't do that, you can however use the path to node directly:

#!/usr/bin/node --harmony

There're more details on Cannot pass an argument to python with "#!/usr/bin/env python"

Community
  • 1
  • 1
OneOfOne
  • 95,033
  • 20
  • 184
  • 185
0

It's works for me. Do u miss a '!'?

<!-- language: lang-js -->
#!/usr/bin/env node --harmony

function* genFunc () {
    console.log('step 1')
    yield 1
    console.log('step 2')
    return 3
}

var gen = genFunc();
var ret = gen.next();
console.log(ret.value);
console.log(ret.done);

ret = gen.next();
console.log(ret.value);
console.log(ret.done);
Jian Lyu
  • 11
  • 3