Problem of Line Wrapping after console Redirects to File

  node.js, question
//test.js
 console.log('hi1');
 console.log('hi2');

After redirection in cmd

node test.js >> test.txt

Txt is “hi1hi2” connected in one line.

hi1hi2

Even after the line break is added

//test2.js
 console.log('hi1\n');
 console.log('hi2');

The result is still in one line
But when I execute the following in cmd

echo hi1 >> test3.txt
 echo hi2 >> test3.txt

Txt content is what I expected

hi1
hi2

At this time, I wonder if all the line breaks in the console do not work.

//test4.js
 console.log('hi1');
 console.log('hi2\nhi3');

After being redirected again, it was still all in one line.

hi1hi2hi3

Want to ask > > isn’t redirection adding content at the end of the file?
Console output does not automatically add line breaks at the end. However, I manually added the new line character “\n”, which does not work after redirection … why? ?
Finally, I hope to realize simple log persistence through the combination of console and redirection. What should I do? ?
(console.error has the same problem as console.log)
Thank you!

Do you use windows? Use the tablet to open it.