简体   繁体   English

有没有办法记录npm install命令的输出

[英]Is there a way to log the output of npm install command

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. 我在一个项目上运行了npm install ,它提供了一些我想要捕获的错误和警告,但是输出太长并且被切断,所以我无法查看终端中的完整列表。

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. 我尝试将其重定向到一个文件,但输出仍然被写入终端,我仍然得到一个只列出依赖树的输出文件。

I also tried to pipe it to less in linux but it still run through many screens until stopped for continue. 我也尝试在Linux中将它管道化为较少,但它仍然通过许多屏幕直到停止继续。

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 doc,它似乎没有日志功能,我想要的是能够在文件中记录确切的输出,我该怎么办?

npm install 2>&1 | tee log.txt

2>&1路由stderr到stdout,所以一切都将在单个流中输出。

You may only be interested in the warnings and errors, if so try this: 您可能只对警告和错误感兴趣,如果是这样,请尝试:

The npm arg is --silent . npm arg是--silent Or npm config set loglevel warn if you want to only print warnings and errors. 或者npm config set loglevel warn您是否只想打印警告和错误。 Or you can pipe it to /dev/null . 或者你可以将它传递给/dev/null

so you have 2 options: 所以你有两个选择:

  1. npm i --silent
  2. npm config set loglevel warn then npm i npm config set loglevel warn then npm i

References: 参考文献:

npm install should be quiet npm安装应该安静

Add option to hide summary output from npm install 添加选项以隐藏npm install的摘要输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM