Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write output of `npm run start` to a file

Tags:

bash

shell

npm

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?

like image 942
sfletche Avatar asked Sep 12 '19 23:09

sfletche


Video Answer


1 Answers

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.

like image 55
Avinash Yadav Avatar answered Oct 31 '22 07:10

Avinash Yadav