Write output of `npm run start` to a file Write output of `npm run start` to a file shell shell

Write output of `npm run start` to a file


This will work

npm run start 2>&1| tee npm.txt

Explanation:

2>&1 will redirect error stderr to stdout and tee command will write terminal output to file.


what worked for me:

npm start >> log.txt 2>> log.txt

>> log.txt to redirect stdout to the file

2>> log.txt to redirect stderr to the file

others use the shorthand &>> for both stdout and stderr but it's not accepted by both my mac and ubuntu :(

extra: > overwrites, while >> appends