繁体   English   中英

Windows:如何在 NPM 中运行时间?

[英]Windows: how do I run time in NPM?

如果我使用的是 Linux,我会知道如何回答这个问题(我认为)。 我会在我的 package.json 作为脚本做这样的事情:

time ls

但我在 Windows 上,我在 cygwin 中运行 NPM。 当我尝试运行此命令时,output 是:

The system cannot accept the time entered.
Enter the new time:

我不确定为什么会这样。 如果我从脚本中删除time ,或者在我的 cygwin 终端中键入time ls ,它的行为与预期相同。 如果我在终端中type time ,它说time is a shell keyword ,如果我让我的脚本运行它,它会出错说: The system cannot find the file specified. 我怀疑这与错误有关,但我不明白为什么会得到它。

如何在 npm 中运行time

由于 Cygwin 中没有npm ,因此您显然是使用第三部分工具。 我假设您使用标准 CMD 作为命令解释器,对于 Bash,您将拥有

$ time ls
bin      doc        Downloads    foo   Music     Public     Videos
Desktop  Documents  figure3.jpg  lftp  Pictures  Templates  Xdefaults

real    0m0.564s
user    0m0.000s
sys     0m0.030s

而你的

The system cannot accept the time entered.
Enter the new time:

相当于我的 CMD(德语)output

C:\Users\Marco>time ls
Eingegebene Zeit kann nicht übernommen werden.
Geben Sie die neue Zeit ein:

bash shell

$ type time
time is a shell keyword

来自info bash

3.2.2 Pipelines
---------------

A 'pipeline' is a sequence of one or more commands separated by one of the control operators '|' or '|&'.

   The format for a pipeline is
     [time [-p]] [!] COMMAND1 [ | or |& COMMAND2 ] ...

The output of each command in the pipeline is connected via a pipe to the input of the next command.  That is, each command reads the previous command's output.  This connection is performed before any redirections specified by the command.

   If '|&' is used, COMMAND1's standard error, in addition to its standard output, is connected to COMMAND2's standard input through the pipe; it is shorthand for '2>&1 |'.  This implicit redirection of the standard error to the standard output is performed after any redirections specified by the command.

   The reserved word 'time' causes timing statistics to be printed for the pipeline once it finishes.  The statistics currently consist of elapsed (wall-clock) time and user and system time consumed by the command's execution.  The '-p' option changes the output format to that specified by POSIX.  When the shell is in POSIX mode (*note Bash POSIX Mode::), it does not recognize 'time' as a reserved word if the next token begins with a '-'.  The 'TIMEFORMAT' variable may be set to a

因此,尝试从 Cygwin bash shell 运行您的脚本。 通常它是 Cygwin 终端中的默认值

暂无
暂无

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

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