Dodaj flagę persmison, aby zapisać plik nodejs

var fs = require('fs');

var stream = fs.createWriteStream('hello.js', { mode: 0o755 });
stream.write("#!/usr/bin/node\n");
stream.write("console.log('hello world');");
stream.end();
Restu Wahyu Saputra