isexe

中文文档
4.0.0发布于 2026/02/10BlueOak-1.0.0TypeScriptESM + CJS零依赖近 30 天下载 14亿

Minimal module to check if a file is executable.

原始使用文档
文档目录6 节
  1. USAGE
  2. API
  3. isexe(path, [options]) => Promise<boolean>
  4. sync(path, [options]) => boolean
  5. Platform Specific Implementations
  6. Options

isexe

Minimal module to check if a file is executable, and a normal file.

Uses fs.stat and tests against the PATHEXT environment variable on Windows.

USAGE

// default export is a minified version that doesn't need to
// load more than one file. Load the 'isexe/raw' export if
// you want the non-minified version for some reason.
import { isexe, sync } from 'isexe'
// or require() works too
// const { isexe } = require('isexe')
isexe('some-file-name').then(
  isExe => {
    if (isExe) {
      console.error('this thing can be run')
    } else {
      console.error('cannot be run')
    }
  },
  err => {
    console.error('probably file doesnt exist or something')
  },
)

// same thing but synchronous, throws errors
isExe = sync('some-file-name')

// treat errors as just "not executable"
const isExe = await isexe('maybe-missing-file', { ignoreErrors: true })
const isExe = sync('maybe-missing-file', { ignoreErrors: true })

API

isexe(path, [options]) => Promise<boolean>

Check if the path is executable.

Will raise whatever errors may be raised by fs.stat, unless options.ignoreErrors is set to true.

sync(path, [options]) => boolean

Same as isexe but returns the value and throws any errors raised.

Platform Specific Implementations

If for some reason you want to use the implementation for a specific platform, you can do that.

import { win32, posix } from 'isexe'
win32.isexe(...)
win32.sync(...)
// etc

// or:
import { isexe, sync } from 'isexe/posix'

The default exported implementation will be chosen based on process.platform.

Options

import type IsexeOptions from 'isexe'
  • ignoreErrors Treat all errors as "no, this is not executable", but don't raise them.
  • uid Number to use as the user id on posix
  • gid Number to use as the group id on posix
  • pathExt List of path extensions to use instead of PATHEXT environment variable on Windows.

版本与发布记录

isexe 共发布 14 个版本,首次发布于 2016/01/17;过去 12 个月发布了 5 个版本。

版本发布日期距今
4.0.0latest2026/02/108 个月前
3.1.52026/02/108 个月前
3.1.42026/02/088 个月前
3.1.32026/02/088 个月前
3.1.22026/02/069 个月前
3.1.12023/08/033 年前

关于 isexe 的常见问题

isexe 是什么?

Minimal module to check if a file is executable.

如何安装 isexe?

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

isexe 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

isexe 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

isexe 需要什么版本的 Node.js?

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

isexe 可以商用吗?

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

isexe 的下载量有多少?

根据 npm 官方下载统计,isexe 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,403,228,467 次,日均约 46,774,282 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

isexe 还在维护吗?

最新版本 4.0.0 发布于 2026/02/10(8 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 5 个;首次发布于 2016/01/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。