当 npm 为 运行 时,如何设置 Windows 控制台的标题?

How to set the title of a Windows console while npm is running?

我已经开始在我的 Windows 机器上开发一个 Web 应用程序项目,为此我使用 npm, bower, and the nodejs HTTP 服务器。

为了更容易启动 HTTP 服务器,我创建了批处理文件:

@echo off
title HTTP Server
npm start

npm start 开始 http-server。为此,我在 packages.json 中有以下条目:

"start": "http-server -a localhost -p 8000 -c-1"

但是当我双击批处理时,打开控制台的标题window先变为npm,然后变为bower。所以它忽略了我自己的标题,而 npm/bower 是 运行.

因为我有很多控制台 windows 打开,我想强制 HTTP server 控制台 window 有我的特定标题。我怎样才能做到这一点?

在您的 packages.json 文件中设置标题:

"start": "title HTTP Server && http-server -a localhost -p 8000 -c-1"

您可以通过添加以下行在 app.js 中设置标题:

process.title = "HTTP Server";