有没有办法记录 npm install 命令的输出 [英] Is there a way to log the output of npm install command

查看:87
本文介绍了有没有办法记录 npm install 命令的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行了 npm install在一个项目中,它给出了许多我想捕获的错误和警告,但输出太长且被切断,因此我无法在终端中查看完整列表.

I ran npm install on a project and it gives a number of errors and warnings that I want to catch, but the output is too long and being cut off so I can't view the full list in the terminal.

我尝试将它重定向到一个文件,但输出仍在写入终端,我仍然得到一个只列出依赖树的输出文件.

I tried redirect it to a file but the output is still being written to the terminal and I still get an output file which only list the dependency trees.

我也尝试在 linux 中将其通过管道传输到 less,但它仍会运行许多屏幕,直到停止以继续.

I also tried to pipe it to less in linux but it still run through many screens until stopped for continue.

我检查了 npm doc,它似乎没有日志功能,我想要的是能够在文件中记录确切的输出,我该怎么做?

I checked npm doc and it doesn't seem to have log functionality, what I want is to be able to log the exact output in a file, how can I do it?

推荐答案

npm install 2>&1 |tee log.txt

2>&1 将 stderr 路由到 stdout,因此所有内容都将在单个流中输出.

The 2>&1 routes stderr to stdout, so everything will output in a single stream.

这篇关于有没有办法记录 npm install 命令的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆