如何使用 `npm list` 命令的日志写入 txt 文件?

How to write a txt file with the log from the `npm list` command?

npm list 记录如下:

如何将其保存为 txt 文件?

适用于较新的 Windows OS 和 Linux/Mac:

npm list > logs.txt