If you write a Node script the prints output to the screen, and try to pipe the output to a file, you can get an error:
$ node extract.js > ideas.csv
output is not a tty
In my case, I was trying to write out a CSV file:
for (var k = 0; k < all.length; k++) {
console.log(all[k]);
}
The solution to this is to open the file directly and write to it:
var fs = require('fs');
var results = '';
for (var k = 0; k < all.length; k++) {
results += all[k] + "\n";
}
fs.writeFile("ideas.csv", results);
The reason this doesn't work as expected appears to be that 'git bash' is passing the command through to the Windows cmd shell, and not handling the output stream correctly. Writing directly to a file avoids the issue entirely.
Instead of modifying your code, just run it thorugh bash.
bash -c “node extract.js > ideas.csv”
It’s working thanks for your valuable input on this
Thank you both, this solved my issue.
I had the same issue with Gitbash on windows. Solved it which bash -c “”.
Thanks for the post (y)