Reputation: 49714
I'd like to capture the output of npm run start
in a file (I'm getting a ton of errors and I'd like to have more control over how I sift through the output).
When I try
npm run start > log.txt
I get a very abbreviated file (8 lines) that ends with [34mℹ[39m [90m「wdm」[39m: Failed to compile.
When I try
npm run start &> log.txt // redirect stderr and stdout to a file
I get a similarly abbreviated file (11 lines) that ends with similarly garbled output.
What am I missing?
Upvotes: 30
Views: 22788
Reputation: 916
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.
Upvotes: 44
Reputation: 1110
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
Upvotes: 9