is-interactive

中文文档
2.0.0发布于 2021/05/04MITES Module零依赖近 30 天下载 3亿

Check if stdout or stderr is interactive

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. API
  4. isInteractive(options?)
  5. FAQ
  6. Related

is-interactive

Check if stdout or stderr is interactive

It checks that the stream is TTY, not a dumb terminal, and not running in a CI.

This can be useful to decide whether to present interactive UI or animations in the terminal.

Install

$ npm install is-interactive

Usage

import isInteractive from 'is-interactive';

isInteractive();
//=> true

API

isInteractive(options?)

options

Type: object

stream

Type: stream.Writable
Default: process.stdout

The stream to check.

FAQ

Why are you not using ci-info for the CI check?

It's silly to have to detect individual CIs. They should identify themselves with the CI environment variable, and most do just that. A manually maintained list of detections will easily get out of date. And if a package using ci-info doesn't update to the latest version all the time, they will not support certain CIs. It also creates unpredictability as you might assume a CI is not supported and then suddenly it gets supported and you didn't account for that. In addition, some of the manual detections are loose and might cause false-positives which could create hard-to-debug bugs.

Why does this even exist? It's just a few lines.

It's not about the number of lines, but rather discoverability and documentation. A lot of people wouldn't even know they need this. Feel free to copy-paste the code if you don't want the dependency. You might also want to read this blog post.

版本与发布记录

is-interactive 共发布 3 个版本,首次发布于 2019/07/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0latest2021/05/045 年前
1.0.02019/07/217 年前
0.1.02019/07/077 年前

关于 is-interactive 的常见问题

is-interactive 是什么?

Check if stdout or stderr is interactive

如何安装 is-interactive?

在项目目录运行 npm install is-interactive,或使用 pnpm add / yarn add / bun add。

is-interactive 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/is-interactive 是否存在。

is-interactive 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

is-interactive 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

is-interactive 可以商用吗?

is-interactive 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

is-interactive 的下载量有多少?

根据 npm 官方下载统计,is-interactive 在 2026/10/06 – 2026/11/04 这 30 天内被下载 301,589,414 次,日均约 10,052,980 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

is-interactive 还在维护吗?

最新版本 2.0.0 发布于 2021/05/04(5 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/07/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。